priority in Decision Table rows in IBM ODM - ibm-odm

If i have 10 rows in my decision table, out of which i want to execute only row 6 and row 4 without disabling the remaining row.
How can we achieve this functionality?
However, in Action Rule we can set the priority, but we cannot set priority for each row in Decision Table.
I've tried searching any option available in Decision Table properties but there's non. Please help with this.

You may need to implement a logic like this : this is a called rule chaining.
a rule(row) makes a modification, and then another rule(row) gets activated, and so on.
This needs the RETE mode to work, please look at ODM documentation for RETE, and keep in mind to set the method "SET NEXT" to update the RETE, in the BOM settings.
This example shows a chaining mechanism with different options based on the initial value of NEXT.
| NEXT ? | CONDITION 2| ACTIVE ? | ACTION 1 | SET NEXT |
| aa1 | bb1 | true | do this1 | aa2 |
| aa2 | bb2 | true | do this2 | aa3 |
| aa3 | bb3 | true | do this3 | aa7 |
| aa4 | bb4 | false | do this4 | aa6 |
| aa5 | bb5 | true | do this5 | aa1 |
| aa6 | bb6 | false | do this6 | xxx |
| aa7 | bb7 | true | do this7 | aa8 |
| aa8 | bb8 | true | do this8 | aa9 |
| aa9 | bb9 | true | do this9 | aa10 |
| aa10 | bb10 | true | do this10 | xxx |
But this is last measure solution!
I don't know your model, the conditions, etc... out of the blue, you may want to rework your conditions because selecting rule in a DT with a priority like is not needed in usual cases, that is to say 99.9% of the time!
However, if the DT conditions columns are all exclusive as a partition, you may have only one rule(row) among the 10 rows that matches provided data at once.Then no need to order the rule execution.
But its not always the case, sometimes some rules(row) in a DT may match, then few row may execute on the same data, this because some condition may overlap.
For example: lets consider this DT with two conditions columns and two rows(rules) and one actions columns.(there is no verbalization, just the logic)
| <= age >= | Date after | action |
| 18 , 21 | 07-MAY-2020 | do this |
| 16 , 20 | 12-MAY-2020 | do that |
In this case, rule condition overlaps and for data with age = 19 and date = 12-JUNE-2020, this two rules(rows) will match, and "do this" and "do that" will be executed.
If the 10 rules(rows) of your DT, are matching with provided data at runtime, the conditions are not exclusive enough, and you may need to change/rework the DT conditions's design:
add new condition columns for example, to discriminate rules(rows).
Or correct overlapping conditions
Let's take the previous sample and add a new discriminating condition column: GENDER for example
| <= age >= | Date after | GENDER | action |
| 18 , 21 | 07-MAY-2020 | M | do this |
| 16 , 20 | 12-MAY-2020 | F | do that |
In this case, the new column will allow to have only one rule to be matched at once.
Or rework the initial conditions
| <= age >= | Date after | action |
| 18 , 21 | 07-MAY-2020 | do this |
| 22 , 24 | 12-MAY-2020 | do that |
Now, even though second condition overlaps,for data with age = 19 and date = 12-JUNE-2020, only first rule(row) will match, and "do this" will be executed.
I am quite puzzled by the fact you want to order things with priorities.
Priorities may help in some peculiar cases(again), but its always a problem if it is used all over the place(e.g. more than 5 priorities in rules) and it becomes a nightmare to maintain because priorities will never convey why a rule should apply before another.
Instead, as a best practice, use a workflow to group rules in ruletask with a sequential tasks ruleflow, whereas a ruletask name conveys the semantic of grouping/separating.
e.g. Init data, data check, data validation, data transformation, etc...
Whenever you need to order rules, use ruletasks in a ruleflow! Then if you need to do so, you may split your DT into 2 decision tables, so that some rule in the first table may apply before other rule in the second decision table.

Related

Excel list of distinct values

I've got a table with a customer email in column A, and the product they bought in column B - there's around 60k rows.
Data
------------------------------------------------------
Email | Product | Time |
------------------------------------------------------
nayena#gmail.com | P1 | 27/02/2020 18:09:41 |
yenaye#hotmail.com | P2 | 28/02/2020 17:09:32 |
nayena#gmail.com | P1 | 29/02/2020 14:05:46 |
yenaye#hotmail.com | P1 | 29/02/2020 13:02:04 |
yenaye#hotmail.com | P2 | 29/02/2020 20:05:21 |
I'm trying to make two new columns
One should be how many distinct products the customer has sold for.
The other should be a list of those distinct products. (Preferably ordered by date, which would be in another column) Desired result:
Desired Result
---------------------------------------------------------------------
Email | Product | Time | Orders | n |
---------------------------------------------------------------------
nayena#gmail.com | P1 | 27/02/2020 18:09:41 | P1 | 1
yenaye#hotmail.com | P2 | 28/02/2020 17:09:32 | P1|P2 | 2
nayena#gmail.com | P1 | 29/02/2020 14:05:46 | P1 | 1
yenaye#hotmail.com | P1 | 29/02/2020 13:02:04 | P1|P2 | 2
yenaye#hotmail.com | P2 | 29/02/2020 20:05:21 | P1|P2 | 2
I've tried something like
=FILTER(B:B,A:A=A2)
but its dropping down the values, spilling into cells below. And it doesn't do unique values.
This is a fairly standard operation in Python but I'd like to know how one does this in excel in the simplest way possible - it should be fairly straight forward I imagine.
I've tried something like
=AGGREGATE(3,0,FILTER(B:B,A:A=A2))
but I'm not clear on how FILTER is passed to AGGREGATE
Can't quite get what you show for your desired output, if you want the orders sorted by date.
One of your customers has P2 as both the earliest and latest, so no matter which way you sort, it will come out P2|P1
The Orders formula below sorts by Date. (No need for sorting in the n formula)
Orders: =TEXTJOIN("|",TRUE,UNIQUE(INDEX(FILTER(SORT($A$2:$C$6,3,1 ),A2 = INDEX(SORT($A$2:$C$6,3,1 ),0,1)),0,2)))
n: =COUNTA(UNIQUE(INDEX(FILTER($A$2:$C$6,A2=$A$2:$A$6),0,2)))
To replicate your Desired Result, you'd have to sort by Product:
Orders: =TEXTJOIN("|",TRUE,UNIQUE(INDEX(FILTER(SORT($A$2:$C$6,2,1 ),A2 = INDEX(SORT($A$2:$C$6,2,1 ),0,1)),0,2)))
Note:
You can use whole column references, but it increases the calculation time significantly
A Power Query solution is also easily doable, but depends on the specifics of exactly how you want the results presented

How to create a column showing if a value is in the bottom 10 values?

I have a large data set that contains details about objects that are currently on an extension. The extensions are given a specific due date. Some of the extensions are past their due date.
I'm struggling to work out how to create a column in PowerPivot for O365 Excel that will return a yes/no value depending on if the object is one of the 5 most overdue extensions. So far nothing I've tried has worked at all.
Example with fake data:
+-----------+---------+--------------------+------------+
| ID | Urgency | Bus Days Remaining | Due Date |
+-----------+---------+--------------------+------------+
| 118017544 | Overdue | -487 | 1/04/2017 |
| 34960939 | Overdue | -97 | 30/09/2018 |
| 10695082 | Overdue | -364 | 20/09/2017 |
| 166236826 | Overdue | -86 | 15/10/2018 |
| 166236826 | Overdue | -86 | 15/10/2018 |
| 34944450 | Overdue | -437 | 9/06/2017 |
| 69427293 | Overdue | -446 | 29/05/2017 |
| 56280961 | Overdue | -437 | 9/06/2017 |
| 12535364 | Overdue | -176 | 11/06/2018 |
| 46296100 | Overdue | -163 | 28/06/2018 |
| 171666963 | Overdue | -122 | 24/08/2018 |
+-----------+---------+--------------------+------------+
The calculated column should be able to put a "Yes" next to 5 rows in this data that are the oldest.
Factors that might be important:
Multiple extensions can share a due date but be separate extensions. This makes me think that the formula needs to be based off of the "Bus Days Remaining" column value
Excel has a function in Pivot Tables where you only show the Top 10 values. This isn't an option for me because using that filter means you cannot drill into the Pivot Tables data.
Any help you could provide would be great :)
Thanks in advance
Please try this formula.
=C2<=SMALL(C$2:C$12,5)
If the 5th and 6th smallest are equal the formula will return TRUE for more than 5 items.

Divide two "Calculated Values" within Spofire Graphical Table

I have a spotfire question. Is it possible to divide two "calculated value" columns in a "graphical table".
I have a Count([Type]) calculated value. I then limit the data within the second calculated value to arrive at a different number of Count[Type].
I would like to divide the two in a third calculated value column.
ie.
Calculated value column 1:
Count([Type]) = 100 (NOT LIMITED)
Calculated value column 2:
Count([Type]) = 50 (Limited to [Type]="Good")
Now I would like to say 50/100 = 0.5 in the third calculated value column.
If it is possible to do this all within one calculated column value that is even better. Graphical Tables do not let you have if statements in the custom expression, the only way is to limit data. So I am struggling, any help is appreciated.
Graphical tables do allow IF() in custom expressions. In order to accomplish this you are going to have to move your logic away from the Limit Data Using Expressions and into your expression directly. Here should be your three Axes expressions:
Count([Type])
Count(If([Type]="Good",[Type]))
Count(If([Type]="Good",[Type])) / Count([Type])
Data Set
+----+------+
| ID | Type |
+----+------+
| 1 | Good |
| 1 | Good |
| 1 | Good |
| 1 | Good |
| 1 | Good |
| 1 | Bad |
| 1 | Bad |
| 1 | Bad |
| 1 | Bad |
| 2 | Good |
| 2 | Good |
| 2 | Good |
| 2 | Good |
| 2 | Bad |
| 2 | Bad |
| 2 | Bad |
| 2 | Bad |
+----+------+
Results

DAX Cumulative Total With Date Filters

I am trying to calculate a running total where orders are only valid during a certain date range. Each order has a value, a start date and an end date. I want to calculate the cumulative sum of the order's values only during the dates between an order's start date and end date.
I've read over this article on cumulative totals and have an equation for the running total but I can't figure out how to filter the equation so that it filter's out an order once the date table is past the order's End Date. The current measure I have is Cumulative Value:=CALCULATE(SUM(Orders[Vaue]), FILTER(ALL('Date'), [Date] <= MAX([Date]))) and I want to add a filter that filters out any orders with an end date past the current date row, similar to this Filter('Order', 'Orders'[Order_End_Date] < 'Date'[Date]). When I try to add this filter though I get an error since 'Date'[Date] is not used in any aggregation.
Below is the data model that I am using and a link to the Excel File with the data model.
The sample Data:
+-----------+
| Date |
+-----------+
| 1/1/2015 |
| 1/2/2015 |
| 1/3/2015 |
| 1/4/2015 |
| 1/5/2015 |
| 1/6/2015 |
| 1/7/2015 |
| 1/8/2015 |
| 1/9/2015 |
| 1/10/2015 |
+-----------+
+----------+------+------------------+----------------+
| Order_Id | Vaue | Order_Start_Date | Order_End_Date |
+----------+------+------------------+----------------+
| 1 | 1 | 1/1/2015 | 1/3/2015 |
| 2 | 3 | 1/2/2015 | |
| 3 | 6 | 1/3/2015 | 1/7/2015 |
| 4 | 7 | 1/5/2015 | |
+----------+------+------------------+----------------+
And the output of the current measure I have and what the correct measure's output should be.
+-----------+-----------------+--------------------------+
| Date | Current Measure | Desired Measure's Output |
+-----------+-----------------+--------------------------+
| 1/1/2015 | 1 | 1 |
| 1/2/2015 | 4 | 4 |
| 1/3/2015 | 10 | 9 |
| 1/4/2015 | 10 | 9 |
| 1/5/2015 | 17 | 16 |
| 1/6/2015 | 17 | 16 |
| 1/7/2015 | 17 | 10 |
| 1/8/2015 | 17 | 10 |
| 1/9/2015 | 17 | 10 |
| 1/10/2015 | 17 | 10 |
+-----------+-----------------+--------------------------+
Cumulative Value2:=CALCULATE(
SUM(Orders[Vaue])
,FILTER(
VALUES(Orders[Order_Start_Date])
,Orders[Order_Start_Date] <= MAX('Date'[Date])
)
,FILTER(
VALUES(Orders[Order_End_Date])
,ISBLANK(Orders[Order_End_Date])
|| Orders[Order_End_Date] >= MAX('Date'[Date])
)
)
Model Diagram (note I took out your date relation - for the limited use case you've provided, it only makes things more complicated):
Note: I will refer to function arguments positionally, with the first argument represented by (1).
So, what we're doing is similar to what you were trying. We've got two FILTER()s, each as an argument to our CALCULATE(). CALCULATE() combines its arguments (2)-(n) in a logical and.
The first FILTER() does essentially what you were already doing, except we are filtering the distinct values of the [Order_Start_Date], comparing them against the current filter context of the pivot table.
The second FILTER() loops over the distinct values of [Order_End_Date], checking two conditions combined in a logical or. We must handle the case of a BLANK [Order_End_Date]. This BLANK is normally implicitly converted to 0 == 1899-12-30, which is less than any date we're considering. In the case of a BLANK, we get a true value from ISBLANK() and the row is returned as a part of FILTER()'s resultset. The other test is simply checking that [Order_End_Date] is greater than the current filter context date in the pivot.
What you are looking for is often called the "event in progress" problem. Here are some posts that will help you to solve your problem.
a solid summary of the problem
a special case
guess this will help on first sight
if you can't get enough - read the complete white paper
I hope this helps.
-Tom

Excel Combining Multiple Rows

I feel like I am missing something simple I would like to do with Excel but I am asking the question incorrectly on Google...here it goes.
I'm taking a look at some Excel sheets for a friend who runs a race timing company. At the end of a race he has an excel sheet with the following format for a series of races
Name | Gender | Age | Race 1 | Race 2 | Race 3
Bob | M | 20 | 1 | |
Al | M | 24 | 2 | |
Bob | M | 20 | | 2 |
Al | M | 24 | | 1 |
::Assume we don't care about time right now, just place::
I would like to do "something" (again I'm not sure what the proper term is, merge in Excel actually merges two adjecent cells together), where I can get the final output such that
Name | Gender | Age | Race 1 | Race 2 | Race 3
Bob | M | 20 | 1 | 2 |
Al | M | 24 | 2 | 1 |
I'm not sure how to collapse the data for the like rows together.
I'm not opposed to writing a little VBA, but I am thinking this is a built in Excel function but I'm not sure what it is called or how to make it "dance".
Thanks!
PivotTable.
The data format is making life a bit more difficult than it needs to be. Rather than having individual columns for race #1, race #2, race #3 etc, it would make life easier to have a column called "Race Number" and arrange the data like this:
Name | Gender | Age | Race Number | Place
Bob | M | 20 | 1 | 1
Al | M | 24 | 1 | 2
Bob | M | 20 | 2 | 2
Al | M | 24 | 2 | 1
This would make things like PivotTable (as suggested by Jason) a lot easier to work with

Resources