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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
itsmeanuj
Helper IV
Helper IV

Choose first instance based on the condition

Hi,

so my data contains ~ 1M rows with more attribute columns than what i have included in the sample data. The Dummy PBIX file is placed here :  https://drive.google.com/file/d/1Yt1m0BUM483OQdsh-_aaaZJn5oQyirjX/view?usp=sharing

 

Now I need 2 visuals -

1st visual - Pie chart. This contains values from "Has Shipment" column. So it should show 1 and 0.
If you notice, data contains multiple instances of IDs. I need to create a measure that would pick up the latest (based on the Stamp column) value of ID & Product Combination. This means that the total on the pie chart should show the total count of unique ID&Product combinations. e.g. for Product B, the count of IDs would be 92 with the split between 1,0 ("has shipment" column)

if the latest (based on the "stamp" column) ID product combination has a value 1 for "has shipment" then, consider 1 and similarly 0 if the latest value is 0

 

2nd visual - this is a simple table visual with details of IDs. Note this count of rows should match the total count in 1st visual. e.g. 92 for Product B.

Please note that this count should be dynamic and adjust itself with the date filter and product filter at the top (see in the attached PBI)

Thanks,
Anuj

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @itsmeanuj ,

I updated your sample pbix file(see the attachment), please check if that is what you want.

1. Create a measure as below

Count of IDs = 
VAR _latestdate =
    CALCULATE ( MAX ( 'Data'[STAMP] ), ALLSELECTED ( 'Data' ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Data'[ID] ),
        FILTER (
            ALLSELECTED ( 'Data' ),
            'Data'[HAS_SHIPMENTS] = SELECTEDVALUE ( 'Data'[HAS_SHIPMENTS] )
                && 'Data'[STAMP] = _latestdate
        )
    )

2. Create a pie chart and table visual

vyiruanmsft_0-1692256818604.png

Best Regards

View solution in original post

2 REPLIES 2
itsmeanuj
Helper IV
Helper IV

@Greg_Deckler @amitchandak - can you please help?

Anonymous
Not applicable

Hi @itsmeanuj ,

I updated your sample pbix file(see the attachment), please check if that is what you want.

1. Create a measure as below

Count of IDs = 
VAR _latestdate =
    CALCULATE ( MAX ( 'Data'[STAMP] ), ALLSELECTED ( 'Data' ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Data'[ID] ),
        FILTER (
            ALLSELECTED ( 'Data' ),
            'Data'[HAS_SHIPMENTS] = SELECTEDVALUE ( 'Data'[HAS_SHIPMENTS] )
                && 'Data'[STAMP] = _latestdate
        )
    )

2. Create a pie chart and table visual

vyiruanmsft_0-1692256818604.png

Best Regards

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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