Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
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
FY21 | aa | Paul | 10 |
FY21 | aa | John | 10 |
FY21 | aa | Philipp | 4 |
FY21 | bb | Philipp | 12 |
FY21 | bb | John | 8 |
FY21 | bb | Paul | 4 |
FY21 | bb | Roger | 2 |
FY20 | aa | Roger | 8 |
FY20 | aa | John | 15 |
FY20 | aa | Philipp | 4 |
FY20 | bb | Paul | 14 |
FY20 | bb | Roger | 8 |
FY20 | bb | John | 2 |
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
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 )
Hi,
Please check the below picture and the attached pbix file.
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 )
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
11 | |
9 | |
6 |