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
carlosyanez
Frequent Visitor

Dynamically filter row based on dates and ID

Hi,

 

I'm currently working on a Dashboard where I need to pick the latest value for one category, with the ability to use a time slicer and then get the latest value within the range of the filter.  The case is as follows::

 

ID1DateValue
A01-Jan-224
A03-Mar-225
A04-Apr-223
B02-Feb-227
C04-Mar-229
C05-Jul-227

 

 

Let's say I have the above table. What I need is to just present the latest row for each ID, i.e.:

 

ID1DateValue
A04-Apr-224
B02-Feb-227
C05-Jul-227

 

But I had a date slicer, with an end date on 5 May, the result would be:

 

ID1DateValue
A04-Apr-224
B02-Feb-227
C04-Mar-229

 

And if the end of the range is set to 3 March, then it needs to present:

 

ID1DateValue
A03-Mar-225
B02-Feb-227

 

 

What would be the best way to achieve this with DAX measures/calculated columns or tables?

 

 

Thanks!

Carlos

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @carlosyanez 

 

try to created two measures and plot a visual table with them. 

 

the code:

DateLatest := MAX(TableName[Date])
ValueLatest :=
VAR DateLatest = MAX(TableName[Date])
RETURN
CALCULATETABLE(
    VALUES(TableName[Value]),
    TableName[Date] = DateLatest
)
 
I tried and it worked like this:
FreemanZ_0-1669651689527.png

 

FreemanZ_1-1669651712121.png

 

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @carlosyanez 

 

try to created two measures and plot a visual table with them. 

 

the code:

DateLatest := MAX(TableName[Date])
ValueLatest :=
VAR DateLatest = MAX(TableName[Date])
RETURN
CALCULATETABLE(
    VALUES(TableName[Value]),
    TableName[Date] = DateLatest
)
 
I tried and it worked like this:
FreemanZ_0-1669651689527.png

 

FreemanZ_1-1669651712121.png

 

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.

Top Solution Authors