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.
Hi,
I need to look through entire column and as soon as "TheOrder" value is found in OrderNumber column, Result will always return Special from then on against this specific CustomerID, regardless if consecutive order numbers are Normal or TheOrder.
Example:
CustomerID OrderNumber Result
1 Normal Basic
2 Normal Basic
1 TheOrder Special
3 Normal Basic
1 Normal Special
2 TheOrder Special
3 TheOrder Special
1 TheOrder Special
1 Normal Special
Thanks in advance!
Solved! Go to Solution.
Hi @chriser ,
It is nearly impossible to make result return special only when the order number occur “the order” unless your data have an increment primary column or a date key than can indicate the sequence of the orderNmuber.
Result = VAR i = [Customer ID] VAR time = [Date Key] VAR t = FILTER ( 'ExampleWithTime', 'ExampleWithTime'[Customer ID] = i ) VAR t_order = FILTER ( t, [OrderNumber] = "TheOrder" ) VAR firstTime = MINX ( t_order, [Date Key] ) VAR specialStatus = COUNTROWS ( t_order ) > 0 RETURN IF ( specialStatus, IF ( time >= firstTime, "Special", "Basic" ), "Basic" )
Or if you do not have such a column, we can go to power query editor to create an index column.
After creating index column, we can create a calculated column similar to the previous one to meet your requirement.
Result = VAR i = [Customer ID] VAR index = [Index] VAR t = FILTER ( 'Example', 'Example'[Customer ID] = i ) VAR t_order = FILTER ( t, [OrderNumber] = "TheOrder" ) VAR firstIndex = MINX ( t_order, [Index] ) VAR specialStatus = COUNTROWS ( t_order ) > 0 RETURN IF ( specialStatus, IF ( index >= firstIndex, "Special", "Basic" ), "Basic" )
BTW, pbix as attached.
Community Support Team _ DongLi
If this post helps, then please consider Accept it as the solution to help the other members find it more
Hi @chriser ,
It is nearly impossible to make result return special only when the order number occur “the order” unless your data have an increment primary column or a date key than can indicate the sequence of the orderNmuber.
Result = VAR i = [Customer ID] VAR time = [Date Key] VAR t = FILTER ( 'ExampleWithTime', 'ExampleWithTime'[Customer ID] = i ) VAR t_order = FILTER ( t, [OrderNumber] = "TheOrder" ) VAR firstTime = MINX ( t_order, [Date Key] ) VAR specialStatus = COUNTROWS ( t_order ) > 0 RETURN IF ( specialStatus, IF ( time >= firstTime, "Special", "Basic" ), "Basic" )
Or if you do not have such a column, we can go to power query editor to create an index column.
After creating index column, we can create a calculated column similar to the previous one to meet your requirement.
Result = VAR i = [Customer ID] VAR index = [Index] VAR t = FILTER ( 'Example', 'Example'[Customer ID] = i ) VAR t_order = FILTER ( t, [OrderNumber] = "TheOrder" ) VAR firstIndex = MINX ( t_order, [Index] ) VAR specialStatus = COUNTROWS ( t_order ) > 0 RETURN IF ( specialStatus, IF ( index >= firstIndex, "Special", "Basic" ), "Basic" )
BTW, pbix as attached.
Community Support Team _ DongLi
If this post helps, then please consider Accept it as the solution to help the other members find it more
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 |
---|---|
110 | |
99 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |