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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.