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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

DAX Exp to get last updated value based on selected filter date

Hi Team,

Please help me out on below.

I am trying to get the DAX expression for high limit value in table based on filter date. I am having a date filter. I am having below table with date, values and tagid. Tagvalues table.

 

DateTAGIDVALUE
10-06-2018130
10-06-2018240
20-11-2018119
20-11-2018229
10-11-2018125
10-11-2018213
01-12-2018256
01-12-2018136
01-11-2018260

 

Requirement: 

 

If we select the date filter with date 05th Dec 2018 I need the value 56 of date 01 Dec 2018 with tagid 2 value as this is the latest updated highest limit value.

 

If we select the date filter as 01 Oct 2018 I need a value 40 of date 10 Jun 2018 as this is the latest value before our date selection. Below is the sql query to understand. 

 

If we select the date filter as 10 Jun 2018 I need a value 40 of date 10 Jun 2018 as this is the latest value before or equal to our date selection. Below is the sql query to understand. 

 

Select top 1 value from  tagvalues where tagid = 2 and date <= selecteddate order by date desc.

 

Please help  me out to get the highest limit value based on the above data I am new to power BI dax expressions.

 

Thanks and Regards,

Dathy

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please create a measure as below:

Measure 2 =
VAR maxdate =
    CALCULATE (
        MAX ( Tagvalue[Date] ),
        FILTER (
            ALL ( Tagvalue ),
            Tagvalue[Date] <= SELECTEDVALUE ( date_master[dt_date] )
        )
    )
RETURN
    CALCULATE (
        MAX ( Tagvalue[VALUE] ),
        FILTER ( ALL ( Tagvalue ), Tagvalue[TAGID] = 2 && Tagvalue[Date] = maxdate )
    )

 1.PNG2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

5 REPLIES 5
Anonymous
Not applicable

Dax measure needed to get value based on max date in slicer date filter applied.
Sales should get sum based on date range applied in slicer filter but the Value should only come based on max date and matching to ID from the row

 

kamran1015_1-1622743915799.png

 

 

Thanks in Advance

 

 

v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please create a measure as below:

Measure 2 =
VAR maxdate =
    CALCULATE (
        MAX ( Tagvalue[Date] ),
        FILTER (
            ALL ( Tagvalue ),
            Tagvalue[Date] <= SELECTEDVALUE ( date_master[dt_date] )
        )
    )
RETURN
    CALCULATE (
        MAX ( Tagvalue[VALUE] ),
        FILTER ( ALL ( Tagvalue ), Tagvalue[TAGID] = 2 && Tagvalue[Date] = maxdate )
    )

 1.PNG2.PNG

 

Best regards,

Yuliana Gu

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

Hi @Anonymous

 

How about

 

Measure =
CALCULATE (
    MAX ( Tagvalues[value] );
    FILTER ( ALL ( 'Date' ); 'Date'[Date] <= MAX ( 'Date'[Date] ) )
)

where 'Date'is your date table?

 

Anonymous
Not applicable

Sorry this expression is not working I am selecting date from date_master[dt_date] table in filter and comparing with date in Tagvalues table I need to check both the filters date_master[dt_date] is less then latest Tagvalue[date] and get the max limit(tagid = 2 ) for higest limit.

 

Thanks,

Vijay D

AlB
Community Champion
Community Champion

@Anonymous

You want it always for tagid =2? It would more convenient to have the tagid in a slicer but give this a try. You'll have to adapt the it with the name of your Date table.

 

Measure =
VAR LatestDate =
    CALCULATE (
        MAX ( Tagvalues[Date] );
        FILTER ( ALL ( 'Date' ); 'Date'[Date] <= MAX ( 'Date'[Date] ) );
        Tagvalues[Tagid] = 2
    )
RETURN
    LOOKUPVALUE (
        Tagvalues[value];
        Tagvalues[Date]; LatestDate;
        Tagvalues[Tagid]; 2
    )

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors