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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
kirwanm1
Frequent Visitor

Distinct Count/Aggregate Ids/Event Logs

Hey everyone,

I have an event log where events are tied by an aggregate_id, and each event has it's own rows

 

Trying to develop a measure that counts the number of aggregate_ids based on row conditions

Scenario 1

Agg_id_1 Offered
Agg_id_2 Offered
Agg_id_2 Accepted
Agg_id_3 Offered
Agg_id_3 Accepted
Agg_id_3 Rejected

Measure 1 -  number of agg_ids that contain just offered,
Measure 2 - Number of agg_ids that have a row with (offered & accepted) & not rejected
Measure 3 - Number of agg_ids that have a offered & accepted & rejected

Not sure where to start... A measure that looks for just offered & accepted and nothing else won't work, since there may be other event log rows there in the future.

Thanks,
Mark.

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @kirwanm1,

 

Based on my test, you should be able to follow steps below to create the three measures your scenario.

 

1. Add three calculate column to indicate if an aggregate_id contains each status.

 

has offered = 
CALCULATE (
    DISTINCTCOUNT ( Table1[status] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[aggregate_ids] ),
        Table1[status] = "Offered"
    )
)
has accepted = 
CALCULATE (
    DISTINCTCOUNT ( Table1[status] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[aggregate_ids] ),
        Table1[status] = "Accepted"
    )
)
has rejected = 
CALCULATE (
    DISTINCTCOUNT ( Table1[status] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[aggregate_ids] ),
        Table1[status] = "Rejected"
    )
)

c1.PNG

 

 

2. Then you should be able to use the formulas below to create the three measures.

 

Measure 1 = 
CALCULATE (
    DISTINCTCOUNT ( Table1[aggregate_ids] ),
    FILTER (
        Table1,
        Table1[has offered] = 1
            && Table1[has accepted] <> 1
            && Table1[has rejected] <> 1
    )
)
Measure 2 = 
CALCULATE (
    DISTINCTCOUNT ( Table1[aggregate_ids] ),
    FILTER (
        Table1,
        Table1[has offered] = 1
            && Table1[has accepted] = 1
            && Table1[has rejected] <> 1
    )
)
Measure 3 = 
CALCULATE (
    DISTINCTCOUNT ( Table1[aggregate_ids] ),
    FILTER (
        Table1,
        Table1[has offered] = 1
            && Table1[has accepted] = 1
            && Table1[has rejected] = 1
    )
)

r1.PNG

 

 

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

1 REPLY 1
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @kirwanm1,

 

Based on my test, you should be able to follow steps below to create the three measures your scenario.

 

1. Add three calculate column to indicate if an aggregate_id contains each status.

 

has offered = 
CALCULATE (
    DISTINCTCOUNT ( Table1[status] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[aggregate_ids] ),
        Table1[status] = "Offered"
    )
)
has accepted = 
CALCULATE (
    DISTINCTCOUNT ( Table1[status] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[aggregate_ids] ),
        Table1[status] = "Accepted"
    )
)
has rejected = 
CALCULATE (
    DISTINCTCOUNT ( Table1[status] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[aggregate_ids] ),
        Table1[status] = "Rejected"
    )
)

c1.PNG

 

 

2. Then you should be able to use the formulas below to create the three measures.

 

Measure 1 = 
CALCULATE (
    DISTINCTCOUNT ( Table1[aggregate_ids] ),
    FILTER (
        Table1,
        Table1[has offered] = 1
            && Table1[has accepted] <> 1
            && Table1[has rejected] <> 1
    )
)
Measure 2 = 
CALCULATE (
    DISTINCTCOUNT ( Table1[aggregate_ids] ),
    FILTER (
        Table1,
        Table1[has offered] = 1
            && Table1[has accepted] = 1
            && Table1[has rejected] <> 1
    )
)
Measure 3 = 
CALCULATE (
    DISTINCTCOUNT ( Table1[aggregate_ids] ),
    FILTER (
        Table1,
        Table1[has offered] = 1
            && Table1[has accepted] = 1
            && Table1[has rejected] = 1
    )
)

r1.PNG

 

 

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.