Forum Discussion

StuartSmith's avatar
StuartSmith
Power Participant
5 years ago
Solved

Latest Date from Multiple Rows

I have a table visual similar to the below and need to filter the table, so it only shows the latest for each coumtry.  

 

Unfiltered Table

CountryDateQty
UK01/09/202010
UK01/10/20209
Germany01/08/20204
Germany01/09/202011
UAE01/07/20206

 

Desired Table

 

CountryDateQty
UK01/10/20209
Germany01/09/202011
UAE01/07/20206

 

I have tried "Latest Date" from the "Invoice Date" value on the table, but  that either doesnt work or do anything as i still have multiple rows for each country.

 

I have tried a "Top N" = 1 visual filter, but that then only shows the most recent month such as October, missing out countries that have a date of September or August.  I tried TOP N = 2, but then that shows multiple country rows.

 

How can I get just the lastest date showing for each country, when they have different latest dates.

 

****************************************************************

I always search and refer to my previous questions, before asking on here ðŸ˜€, but my boss is constantly thinking up more and more weird and wonderful report requirements.. 

  • v-yingjl's avatar
    v-yingjl
    5 years ago

    Hi StuartSmith ,

    To make the card visual show the same total in the table visual, you can create another measure to calculate it and put it in the card visual:

    Sum of Qty = 
    CALCULATE ( SUM ( 'Table'[Qty] ), FILTER ( ALL ( 'Table' ), [Control] = 1 ) )

    Check the modified sample file in the below, hopes to help you.

     

    Best Regards,
    Yingjie Li

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

13 Replies

  • v-yingjl's avatar
    v-yingjl
    Community Support

    Hi StuartSmith ,

    You can create this measure, put it in the visual filter and set its value as 1:

    Control =
    VAR _max =
        CALCULATE (
            MAX ( 'Table'[Date] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Country] IN DISTINCT ( 'Table'[Country] ) )
        )
    RETURN
        IF ( SELECTEDVALUE ( 'Table'[Date] ) = _max, 1, 0 )
    

    Attached a sample file in the below, hopes to help you.

     

    Best Regards,
    Yingjie Li

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

    • StuartSmith's avatar
      StuartSmith
      Power Participant

      v-yingjl Not to sure if you can assist further, your solution works exactly as I asked, but I have noticed that there are 2 rows that dont have invoice dates and therefore flagged as "0" and therefore not displayed in the table.  I need these rows to be displayed as well.  Is this possible?