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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Stoned_Edge10
Frequent Visitor

Filtering a table to show unique ID, latest date per unique ID and then sum up those related values

Hi there all,

 

I'm recently returning to Power BI after a 2 year hiatus and I've forgotten a lot of basic things, like row and filter context, how calculate works... funny how all this happens, hopefully it comes back to me soon. 

 

What I am trying to achieve is basically a KPI "card" that shows the number of customers my company currently has. 

The current table looks like this:

 

Client IDLastDate (Per Client)VenueNumber
109/01/2022100
109/09/2022200
110/01/2022300
209/01/2022400
210/01/2022100
308/01/2022200
309/01/2022300
310/01/2022400
410/01/2022500
 
n n

 

And this is the output I would like to achieve, using a DAX measure (eventually summing the total venue numbers), with the below table being fiterable with my date table (i.e by year, by month, etc) - its essentially a running total of venues. 

Client IDLastDate (Per Client)VenueNumber
110/01/2022300
210/01/2022100
310/01/2022400
410/01/2022500
 
n n

 

If anyone could help me achieve this with a DAX measure it would be much appreciated! 

Looking forward to hopping back into the Power BI scene (last I used this was 2018 during an internship!)

 

Kind regards,

StonedEdge

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Stoned_Edge10 ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[LastDate (Per Client)] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Client ID] = SELECTEDVALUE ( 'Table'[Client ID] )
        )
    )
RETURN
    IF ( MAX ( 'Table'[LastDate (Per Client)] ) = _maxdate, 1, BLANK () )

Then filter the measure.

vpollymsft_0-1652765868274.pngvpollymsft_1-1652765881264.png

If I have misunderstood your meaning, pleas provide more details with your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Stoned_Edge10 ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[LastDate (Per Client)] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Client ID] = SELECTEDVALUE ( 'Table'[Client ID] )
        )
    )
RETURN
    IF ( MAX ( 'Table'[LastDate (Per Client)] ) = _maxdate, 1, BLANK () )

Then filter the measure.

vpollymsft_0-1652765868274.pngvpollymsft_1-1652765881264.png

If I have misunderstood your meaning, pleas provide more details with your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

 

 

 

Anonymous
Not applicable

Why this approach doesnt work if you have matrix visual?

SpartaBI
Community Champion
Community Champion

@Stoned_Edge10  create these measures:

 

Last Date (Per Client) Measure = MAX(Clients[Date])

Venue Number Measure = 
SUMX(
    VALUES(Clients[Client ID]),
    VAR _current_client = Clients[Client ID]
    VAR _max_date = [Last Date (Per Client)]
    VAR _venue = 
        MAXX(
            FILTER(
                Clients,
                Clients[Client ID] = _current_client && Clients[Date] = _max_date
            ),
            Clients[VenueNumber]
        )
    RETURN
        _venue
)

 

 

SpartaBI_0-1652459196417.png

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.