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.
Hi
I am new to this forum & also to DAX. I have a Power BI model with data in columns A, B, C & D. I want to calculate the sum using a measure to sum as it appears in columns E & F. These are sums of columns C & D based on column A. Column A can repeat but I want to calculate it only once. Also, I want to calculate the Average & Median of these calculated measures. How to get this using DAX.
Seeking help from the community on how to address this and get the desired result.
Solved! Go to Solution.
Try measures like
Sumx(summarize(Table, Table[Project], Table[Hour]), [Hour])
Sumx(summarize(Table, Table[Project], Table[$]), [$])
Hi @reachkrs ,
Not quite sure about the calculated logic of Sum Measure Result Hours. But you may try the following Measures.
Result $ Measure =
VAR minLine =
CALCULATE (
MIN ( 'Table'[Line] ),
ALLEXCEPT ( 'Table', 'Table'[Project], 'Table'[Hour] )
)
VAR NotRepeat =
IF ( MAX ( 'Table'[Line] ) = minLine, MAX ( 'Table'[$] ), 0 )
RETURN
NotRepeat
Sum Measure Result $ = SUMX('Table',[Result $ Measure])
Average Sum $ = AVERAGEX('Table',[Sum Measure Result $])
Median Sum $ = MEDIANX('Table',[Sum Measure Result $])
The result looks like this.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi
Thank you. The code provided by you gives exact result.
This solves my problem.
Hi @reachkrs ,
Not quite sure about the calculated logic of Sum Measure Result Hours. But you may try the following Measures.
Result $ Measure =
VAR minLine =
CALCULATE (
MIN ( 'Table'[Line] ),
ALLEXCEPT ( 'Table', 'Table'[Project], 'Table'[Hour] )
)
VAR NotRepeat =
IF ( MAX ( 'Table'[Line] ) = minLine, MAX ( 'Table'[$] ), 0 )
RETURN
NotRepeat
Sum Measure Result $ = SUMX('Table',[Result $ Measure])
Average Sum $ = AVERAGEX('Table',[Sum Measure Result $])
Median Sum $ = MEDIANX('Table',[Sum Measure Result $])
The result looks like this.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi
Thank you. The code provided by you gives exact result.
This solves my problem.
Thank you Amit. Sumx works perfectly.
Is it possible to calculate average & median of these values ?. Since these are Measures Median, Average functions do not accept these as parameters.
Try measures like
Sumx(summarize(Table, Table[Project], Table[Hour]), [Hour])
Sumx(summarize(Table, Table[Project], Table[$]), [$])
User | Count |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
7 |