Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

How to determine the order of occurrence based on filter criteria and order of another column

I have a dataset about workflows with unique information about each step in a workflow. I have a column titled "critical" and I have the "order" of the steps per each workflow. I'm interested in finding the order of occurrence for when "critical"="true".

 

Note: The "order" of steps is not in chronological order so I need to account for that in my query/DAX function

Here is an example of my dataset:

Workflow IDOrderCritical
230false
233true
231true
232false
234false
540true
541false
543true
542false

 

I would like to return a column (possibly like the one below) so that I can use it in calculations to determine dates between these critical steps

Workflow IDOrderCriticalOccurrence of Critical
230falsenull
233true2
231true1
232falsenull
234falsenull
540true1
541falsenull
543true2
542falsenull

 

Thank you for all help! I've been working on this problem for a while and haven't come up with a good way to handle the order of this "critical" column.

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can create a calculated column as below:

Column = IF('Table'[Critical]=FALSE(),BLANK(),RANKX(FILTER('Table','Table'[Workflow ID]=EARLIER('Table'[Workflow ID])&&'Table'[Critical]=TRUE()),'Table'[Order],,ASC,Dense))

Or a measure as below:

Measure = IF(SELECTEDVALUE('Table'[Critical])=FALSE(),"null",RANKX(FILTER(ALL('Table'),'Table'[Workflow ID]=MAX('Table'[Workflow ID])&&'Table'[Critical]=TRUE()),CALCULATE(MAX('Table'[Order])),,ASC,Dense))

And you will see:

Screenshot 2020-10-26 142848.png

For the related .pbix file,pls see attached.

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

1 REPLY 1
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can create a calculated column as below:

Column = IF('Table'[Critical]=FALSE(),BLANK(),RANKX(FILTER('Table','Table'[Workflow ID]=EARLIER('Table'[Workflow ID])&&'Table'[Critical]=TRUE()),'Table'[Order],,ASC,Dense))

Or a measure as below:

Measure = IF(SELECTEDVALUE('Table'[Critical])=FALSE(),"null",RANKX(FILTER(ALL('Table'),'Table'[Workflow ID]=MAX('Table'[Workflow ID])&&'Table'[Critical]=TRUE()),CALCULATE(MAX('Table'[Order])),,ASC,Dense))

And you will see:

Screenshot 2020-10-26 142848.png

For the related .pbix file,pls see attached.

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.