Forum Discussion

artp3642's avatar
artp3642
New Member
4 years ago
Solved

How to filter latest dates using a measure?

I have the a table with many values for each date, and a column named type and other name type2 that distinguishes each record from each other. So it is:

 

type1type2valuedate
M_0conv514/02/2022
M_0spread1014/02/2022
M_1conv1514/02/2022

 

I tried to filter using the following code:

 

Medida = VAR ultima = CALCULATE ( MAX ( Table1[date] ), ALL ( Table1 ) ) RETURN IF ( MIN ( Table1[date] ) = maxDate, 1, 0 )

 

Unfortunately it doesnt work.

I also tried creating a column with value 1 on the latest date, and 0 elsewhere. But even adding a slicer and filtering it value dosn't work.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi artp3642 ,

    you can try for 

    Medida = 
    VAR ultima = CALCULATE(MAX(Table1[date]),ALL(Table1)) 
    RETURN
    IF(
       Table1[date]) = ultima,1,0
      )

    Regards,
    Aditya

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi artp3642 ,

    you can try for 

    Medida = 
    VAR ultima = CALCULATE(MAX(Table1[date]),ALL(Table1)) 
    RETURN
    IF(
       Table1[date]) = ultima,1,0
      )

    Regards,
    Aditya

  • artp3642 , Try for column

     

    Medida =
    VAR ultima = CALCULATE MAX ( Table1[date] )
    RETURN
    IF (Table1[date] = maxDate, 1, 0 )

     

    what you have written is for a measure