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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Two level chain of context/measures with DAX

Hello,

 

I have following scenario: a few persons attend to various events spread over yearly period. Each person is rewarded by a number of points for each event, the number can vary depending on the event.

 

The target consists in calculating the percentage of points for each candidate compared to the maximum possible during the given period. The maximum possible is defined by the sum for all events of the highest number of points obtained by the best performer for the local event. In case two candidates are best performers of course only one value shall be counted in the sum. See illustration for an example.

 

nestedpict.png

 

The maximum by event can be obtained by DAX command as shown in the bottom of the picture. The sum of the max by period is more difficult because of the complexity of combining change of context and measure of a measure. What is the way to go here?  

The constraint is to do it with DAX, and let the door open to have user interactivity on period, event and name selection.

 

Thank you for your support and have a nice day

 

Input data:

 

Period     Event      Name    Amount

FY21aaPaul10
FY21aaJohn10
FY21aaPhilipp4
FY21bbPhilipp12
FY21bbJohn8
FY21bbPaul4
FY21bbRoger2
FY20aaRoger8
FY20aaJohn15
FY20aaPhilipp4
FY20bbPaul14
FY20bbRoger8
FY20bbJohn2
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1668065349519.png

 

 

Jihwan_Kim_0-1668065326551.png

 

 

Expected result measure: =
VAR _numerator = [Amount measure:]
VAR _denominator =
    SUMX (
        GROUPBY (
            ADDCOLUMNS (
                SUMMARIZE (
                    CALCULATETABLE ( Data, ALL ( 'Name' ), ALL ( Event ) ),
                    Event[Event],
                    'Name'[Name]
                ),
                "@amount", CALCULATE ( SUM ( Data[Amount] ) )
            ),
            Event[Event],
            "@maxbyevent", MAXX ( CURRENTGROUP (), [@amount] )
        ),
        [@maxbyevent]
    )
RETURN
    DIVIDE ( _numerator, _denominator )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

Here's a solution that uses very short and sweet measures and highlights things on the visuals... You can do the rest EASILY yourself 🙂 The measures are relative to what's visible in the visuals. Play with this to see for yourself.

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1668065349519.png

 

 

Jihwan_Kim_0-1668065326551.png

 

 

Expected result measure: =
VAR _numerator = [Amount measure:]
VAR _denominator =
    SUMX (
        GROUPBY (
            ADDCOLUMNS (
                SUMMARIZE (
                    CALCULATETABLE ( Data, ALL ( 'Name' ), ALL ( Event ) ),
                    Event[Event],
                    'Name'[Name]
                ),
                "@amount", CALCULATE ( SUM ( Data[Amount] ) )
            ),
            Event[Event],
            "@maxbyevent", MAXX ( CURRENTGROUP (), [@amount] )
        ),
        [@maxbyevent]
    )
RETURN
    DIVIDE ( _numerator, _denominator )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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