Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

how to get the value when date=max selected date range

Hi, I have a series of data like this:

date value
22/12/2022 2
23/12/2022 0
24/12/2022 0
25/12/2022 7
26/12/2022 3
27/12/2022 0
28/12/2022 0
29/12/2022 0
30/12/2022 5

I created a date range slicer use date column in the same table,

now I want to make it return the data that date is the max selected date,

for example, when I selecte date range start from 22/12/2022 to 26/12/2022, returns value in box visual 3, and if I select the ate range start from 25/12/2022 to 30/12/2022, the value should return 5, do you know how to create such a measure?

for some reasons new date table should not be created, so I am asking a solution that use the date column as date range slicer from the same table

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    Here I suggest you to try ALLSELECTED() function to create measures.

    Value on Max Date in Date Range = 
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( ALLSELECTED('Table'), 'Table'[date] = MAX('Table'[date]))
    )

    Result is as below.

     

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks, actually  I am asking a solution that use the date column as date range slicer from the same table, so this method does not work for me

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Here I suggest you to try ALLSELECTED() function to create measures.

        Value on Max Date in Date Range = 
        CALCULATE (
            SUM ( 'Table'[value] ),
            FILTER ( ALLSELECTED('Table'), 'Table'[date] = MAX('Table'[date]))
        )

        Result is as below.

         

         

        Best Regards,
        Rico Zhou

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.