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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
JoeCrozier
Helper II
Helper II

Filter a table visual by latest date

I have a question very similar to this one: https://community.fabric.microsoft.com/t5/Desktop/Power-BI-table-visual-to-get-only-latest-date-valu...

 

I have a table visual that looks like this:

JoeCrozier_0-1689606392876.png

covered the numbers for PHI, but in the "Protocol No" column its the name of a study, lets say like "LS-P-Tylenol" and in the "Sequence Number" column its a number that represents a patient.  Lets say "105".

Well the problem is right now this table will have like 50 rows for a single patient.  It'll say protocol no: "LS-P-Advil" and sequence number: "402" over and over and over, one row for every visit date they have planned..

So I'd love to filter this table by the soonest (from today) "planned visit date" per patient.

Problem is: this visual comes from three separate queries (otherwise I'd filter in the query):

JoeCrozier_1-1689606617845.png



based on that other answer I've tried a few things.  First thing I tried was summarizing planned visit date by latest (or earliest):

JoeCrozier_2-1689606688525.png

 

I'm not really sure what that does but I'll still have multiple rows per patient.

I also tried a filter on the visual like this:

JoeCrozier_3-1689606812635.png

 

It definitely filtered the results, but not sure how?  I'm left with only like 30 rows (should be hundreds) and for the people left, its not even their most recent visit date.

Any ideas?

 

1 ACCEPTED SOLUTION

Hello, I've tried to replicate the datasets, you can use a measure to calulate the latest date for the ID. Navigate to modelling tab, and then New Measure. In the formula bar enter this formula 

Latest Visit = CALCULATE(MAX('Sheet1'[Date]), ALLEXCEPT('Sheet1', 'Sheet1'[Seq])). Change the Sheet1 name with your table name. Then you can bring this measure to your table/matrix 

AbhinavJoshi_0-1689623812503.png

AbhinavJoshi_1-1689623865859.png

I hope it helps! 

View solution in original post

3 REPLIES 3
AbhinavJoshi
Responsive Resident
Responsive Resident

Hi @JoeCrozier. Are you looking to filter by date let's say after May 31, 2023, or you are looking to sort the results by earliest date. If sorting helps you, go to the the Data View, navigate to the table, and in the Column Tools, select sort by column "Ascending or Descending". Hope it hepls 

@AbhinavJoshi thank you for replying!  

JoeCrozier_1-1689616387486.png

 

So our intent with this page is really just to check that for each subject, they do or do not have an upcoming planned visit date.  So as you can see in the above photo, that subject outlined in the middle is shown in three rows, his/her next 3 visits.  Well, I dont need all three of his visits, a row for each.   I just need ONE row with their next visit.  So i'd love to filter to one row for that '158' patient.  Does my phrasing make sense?

Hello, I've tried to replicate the datasets, you can use a measure to calulate the latest date for the ID. Navigate to modelling tab, and then New Measure. In the formula bar enter this formula 

Latest Visit = CALCULATE(MAX('Sheet1'[Date]), ALLEXCEPT('Sheet1', 'Sheet1'[Seq])). Change the Sheet1 name with your table name. Then you can bring this measure to your table/matrix 

AbhinavJoshi_0-1689623812503.png

AbhinavJoshi_1-1689623865859.png

I hope it helps! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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