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

Latest Status per ID based on Date Slicer

Hey Datanauts,

 

I am hitting a roadblock in my project and could really use your help. I have a table which record the timestamp and change in status of each id as shown below:

 

Ticket_IDEdit_DatetimeChange_Status
0011/5/2020 12:00New
0011/6/2020 12:00Approved
0011/7/2020 12:00Investigating
0011/7/2020 14:00Closed
0021/6/2020 12:00New
0021/7/2020 13:00Approved
0021/7/2020 16:00Escalated
0021/9/2020 08:00Closed

 

I am trying to extract the latest value per ID based on a max value of  a date slicer. For example, if i set the max date slicer to 1/8/2020, I hope to get the following result.

 

Ticket_IDEdit_DatetimeChange_Status
0011/7/2020 14:00Closed
0021/7/2020 16:00Escalated

 

I have tried LASTNONBLANK, MAX, LASTDATE, but cant get to the right DAX expression. This is my current expression:

 

Latest Status=
var Max_Date = MAX('Table'[Edit_Datetime])
RETURN
CALCULATE(LASTNONBLANK('Table'[Change_Status],1), 'Table'[Edit_Datetime] <= Max_Date)
 
Thanks for the help in advance.
1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

For your case, just use this formula

Latest Status = 
var Max_Date= CALCULATE(MAX('Table'[Edit_Datetime]),FILTER(ALLSELECTED('Table'),'Table'[Ticket_ID]=MAX('Table'[Ticket_ID]))) return
CALCULATE(MAX('Table'[Change_Status]), FILTER('Table','Table'[Edit_Datetime] = Max_Date))

Result:

4.JPG

and here is sampel pbix file, please try it.

 

 

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.

View solution in original post

12 REPLIES 12
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

For your case, just use this formula

Latest Status = 
var Max_Date= CALCULATE(MAX('Table'[Edit_Datetime]),FILTER(ALLSELECTED('Table'),'Table'[Ticket_ID]=MAX('Table'[Ticket_ID]))) return
CALCULATE(MAX('Table'[Change_Status]), FILTER('Table','Table'[Edit_Datetime] = Max_Date))

Result:

4.JPG

and here is sampel pbix file, please try it.

 

 

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 is great thanks. It works great when using a dates slicer without any other external filters. How can I adapt this measure to ignore other external filters. e.g. in my table we have a 'stage' column. when I don't have any external filters it shows 5 records for stage x. But when I use an external filter (slicer) to slice the table by stage x it shows 9 records. The desired result is to still show 5 even when filtered externally. I hope this makes sense.

Hi,

Share some data to work with, explain the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish,

 

Thanks for getting back to me so promptly. I'll share some screenshots of the issue I'm facing, and if needed will share some data.

 

In both screenshots the table visual is filtered where the latest status measure is not blank. We use the load date slicer to see the latest versions of references and their statuses during the date range selected. This works fine and as you can see we are seeing 11 references with 'approved' status. This is the desired result.

 

However, in the second screenshot I've set the status slicer to approved, but the table visual shows 19 records. The expected result is that the result should be 11 approved records (i.e. the same records as the first screenshot).

 

Thanks in advance.

 

SCD2 Correct.pngSCD2 Status Slicer.png

Hi,

What happens when you turn off interaction between the status slicer and the visual?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish, when I turn off the interaction the table visual has no reaction to the slicer (i.e. nothing changes). This isn't the desired result as we would still want to isolate the status according to what's selected in the slicer (e.g. show the approved count in the first screenshot as per the example above and not the 19 records in the second screenshot).

 

Thanks in advance.

My suggestion should work.  Please retry.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish, what is the suggestion? If, turning off the intercation between the status slicer and the table visual, this doesn't work (see my repsponse above). Apologies if I'm confusing matters.

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@v-lili6-msft Than you for your help once again. I tried your measure and it worked perfectly for showing the latest status, but when i ask it to count the number of tickets with a particular latest status, it will pop an error. I tried to modify the measure you gave, but I am not that well versed with the filter function in your measure. Would appreciate your help if you can. 🙂 

Anonymous
Not applicable

Hey @v-lili6-msft

 

That worked perfectly. Thanks so much for your response. 😀

amitchandak
Super User
Super User

Try

Latest Status=
var Max_Date = MAX('Table'[Edit_Datetime])
RETURN
CALCULATE(LASTNONBLANK('Table'[Change_Status],1),values(Ticket_id), 'Table'[Edit_Datetime] <= Max_Date)

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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.