Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have a table which contains order id's and each order id can have multiple products.
I want to create a column wherein whenever it encounters the order id, the value 1 is entered into the column else 0 and it also checks the condition if there is only one instance of the order_id.
Below is the screenshot of the sample data.
Below is the screenshot of the desired output
Any help is highly appreciated.
Solved! Go to Solution.
Hey,
here is DAX statement that creates a calculated column
flag = var currentOrderID = 'Table1'[order_id] var minID = CALCULATE( MIN('Table1'[id]) ,FILTER(ALL(Table1) ,'Table1'[order_id] = currentOrderID ) ) return IF(AND('Table1'[order_id] = currentOrderID, 'Table1'[id] = minID), 1,0)
Here is a little screenshot from my tiny sample data 🙂
Hopefully this is what you are looking for
Regards
Tom
Hey,
I do not fully understand your requirement, so I try to rephrase what I understand:
Flag each row with 1 where the order appears the first time, otherwise flag the row with 0.
Given that my understanding is correct, I assume it is also valid to sort the columns by: order_id DESCENDING and id DESCENDING
Do you want this be done in the QueryEditor or done by a DAX statement creating a calculated column.
Regards
Tom
You are right. I want to do it using DAX statement
Hey,
here is DAX statement that creates a calculated column
flag = var currentOrderID = 'Table1'[order_id] var minID = CALCULATE( MIN('Table1'[id]) ,FILTER(ALL(Table1) ,'Table1'[order_id] = currentOrderID ) ) return IF(AND('Table1'[order_id] = currentOrderID, 'Table1'[id] = minID), 1,0)
Here is a little screenshot from my tiny sample data 🙂
Hopefully this is what you are looking for
Regards
Tom
Thank you so much Tom. It worked
Your welcome 🙂
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
98 | |
78 | |
65 | |
60 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |