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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
WBscooby
Helper III
Helper III

Measure to filter table and then aggregate scores

Hi

I have a table of events and event scores. Dummy file attached.

I am trying to create a table which will show aggregate scores for PersonIDs for a given time period.

A person can have several Instance_IDs. I only want to select one instance_ID per personID. The logic for this is to count the most Event with the maximum seriousness. If there is more than one event with the same seriousness, I want to count the most recent Instance_ID by start date.

I have written a measure for this logic and have tested each stage individually. It seems to work. However, I am struggling to then use this to aggregate the scores.

Can anyone help. I need to use this methodology for a number of measures. I can't do this as a calculated column as the date range used needs to be dynamic - sometimes based on a whole year, sometimes quarters.

Thank you

 

Here is my dax code that I essentially need to use to filter the table:

MaxSeriousness =
VAR CountEvents = CALCULATE(
    COUNTROWS('Events'),
    ALLEXCEPT('Events', 'Events'[PersonID])
)
VAR MaxSeriousness = CALCULATE(
    MAX('Events'[Seriousness]),
    ALLEXCEPT('Events', 'Events'[PersonID])
)
VAR CountMostSerious = CALCULATE(
    COUNTROWS('Events'),
    ALLEXCEPT('Events', Events[PersonID]),
    Events[Seriousness] = MaxSeriousness
)
VAR MaxStartDateMostSerious = CALCULATE(
    MAX('Events'[START_DATE]),
    ALLEXCEPT('Events', Events[PersonID]),
    Events[Seriousness] = MaxSeriousness
)

Var Result = IF(
        CountEvents = 1 ||
        (CountMostSerious = 1 && MIN('Events'[Seriousness]) = MaxSeriousness) ||
        (MIN('Events'[Seriousness]) = MaxSeriousness && MIN('Events'[START_DATE]) = MaxStartDateMostSerious),
        1,
        0
    )

RETURN
 
    Result

 

https://url.uk.m.mimecastprotect.com/s/l9H4CZVyXHQD32KHzjqa4?domain=1drv.ms

2 REPLIES 2
Anonymous
Not applicable

Hi @WBscooby 

 

I can't open your link because of security policy, if I understand correctly, are you trying to find the sum of the scores for which the measure you gave returned a result of 1? If so, try the following formula:

SUMX(FILTER(ALL('YourTableName'), [Result] = 1), [YourScoresName])

 

If you are still having problems, please present the example data and your expected results as screenshots. Thank you for your time and efforts in advance.

 

Best Regards,
Yulia Xu

 

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

Thanks for looking at this @Anonymous

Does this link work?
https://1drv.ms/u/s!Ap6q8W-mvm27hKhFtwCabVyr8U-TDg?e=xYuhPL

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.

Top Solution Authors