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

Counting followup cases

Hello,

 

I'm quite new to PowerBI, I need some assistance on trying to count the number of followup cases. I will give an example below.

If I have a table which has the following information:

 

DateCase Number
2020-04-201
2020-04-202
2020-04-203
2020-04-204
2020-04-221
2020-04-231
2020-04-302
2020-04-273

 

I'm trying to count the number of followup cases, possibly a column that flags that the occurance of this case is a followup. My final result is to get a table to plot the number of cases and number of followup cases over time.

 

I'm thinking if I can get a measure/column that would produce a result as follows, it would help:

 

 

DateCase NumberIsFollowup
2020-04-2010
2020-04-2020
2020-04-2030
2020-04-2040
2020-04-2211
2020-04-2311
2020-04-3021
2020-04-2731

 

Hope the above made sense. Thank you 

6 REPLIES 6
harshnathani
Community Champion
Community Champion

HI @Anonymous ,

 

You can try this measure

 

Flag Cases = 
VAR cnt = CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Case Number] ) )
RETURN

SWITCH(
    TRUE(),
    MAX('Table'[Date]) = MINX(ALLEXCEPT('Table','Table'[Case Number]),'Table'[Date]) , 0,
    cnt > 1, 1, 0
)

 

 

1.jpg

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

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

Anonymous
Not applicable

@harshnathani 

 

Hello, for some reason my flag case isn't doing what yours does. Instead it's flagging all of them as 1 even if it's the first instance the case has appeared. Basically if a case number has more than one it flags it regardless of whether it's the first instance or the subsequent instances. 

hi @Anonymous 

If you do the filter in the report? if so, please use ALLSELECTED instead of ALLEXCEPT as below:

New Flag Cases = 
VAR cnt = CALCULATE ( COUNTROWS ( 'Table' ), FILTER(ALLSELECTED(  'Table'), 'Table'[Case Number] =MAX('Table'[Case Number])) )
RETURN

SWITCH(
    TRUE(),
    MAX('Table'[Date]) = MINX(FILTER(ALLSELECTED(  'Table'), 'Table'[Case Number] =MAX('Table'[Case Number])),'Table'[Date]) , 0,
    cnt > 1, 1, 0
)

 

If not your case, please share your sample pbix file and your expected output, that will be a great help.

You can upload it to OneDrive for business and post the link here. Do mask sensitive data before uploading.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

This didn't seem to work either. It flagged them all 0. I found a different way to do it. I used rankx to get the index per case, then I counted all the indices that were > 1 so that should only count the followups. 

hi  @Anonymous 

Please share your sample pbix file for us to have a test.

You can upload it to OneDrive for business and post the link here. Do mask sensitive data before uploading.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.