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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
hmattje
Frequent Visitor

Challenge - Count most recent rows for each Dataset - filtered by a date slicer

Hi All, 

I need help to create a measure in dax.

My problem is I need to create a bar chart to show Count of "Columns" by "Category" it is simple, but I need to only count columns of latest records for each Dataset according date slicer filter .
As you can see on image below i have a sample of results with different dates slicer .

I can't use distinctcount(Column), because there are different categories with the same column.
Thank you.

Sample File

 

hmattje_0-1669136297345.png

 

1 ACCEPTED SOLUTION

Thanks for your reply
I managed to do it using this measure below

SUMX(
    ADDCOLUMNS(
        VALUES(Registration[Dataset]),
        "Count",
        VAR vDataMax =
            CALCULATE(
                MAX(Registration[Date]),
                ALLEXCEPT(Registration, Registration[Dataset]), 'Date'[Date] >= MIN('Date'[Date]) && 'Date'[Date] <= MAX('Date'[Date])
            )
        RETURN
        COUNTROWS(
            FILTER(
                SUMMARIZE(
                    Registration,
                    Registration[Date],
                    Registration[Dataset],
                    Registration[Column],
                    Registration[Type]
                ),
                Registration[Date] = vDataMax
            )
        )
    ),
    [Count]
)

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@hmattje , refer if these can help

 

Latest
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your reply
I managed to do it using this measure below

SUMX(
    ADDCOLUMNS(
        VALUES(Registration[Dataset]),
        "Count",
        VAR vDataMax =
            CALCULATE(
                MAX(Registration[Date]),
                ALLEXCEPT(Registration, Registration[Dataset]), 'Date'[Date] >= MIN('Date'[Date]) && 'Date'[Date] <= MAX('Date'[Date])
            )
        RETURN
        COUNTROWS(
            FILTER(
                SUMMARIZE(
                    Registration,
                    Registration[Date],
                    Registration[Dataset],
                    Registration[Column],
                    Registration[Type]
                ),
                Registration[Date] = vDataMax
            )
        )
    ),
    [Count]
)

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.