Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi guys,
I haven't found any answer related to my problem, that's why i'm oppening this topic.
First off, let me show the DAX measure:
REFERENCE | VALUE | MEASURE |
Row | 5490,31 | This value resulting is above 0, so it shows the sum of the values. |
Row | 0,00 | The first IF condition is met, where the value resulting is negative (442,12 - (-2295,46) = -1853,34), so it returns 0. |
WRONG GRAND TOTAL | 3636,97 | Returns the result of 5490,31 + 442,12 - (-2295,46) = 3636,97. Wrong. |
RIGHT GRAND TOTAL | 5490,31 | The expected result. It should return the sum of 5490,31 - 0 = 5490,31. Right. |
There's a way to do it without creating a calculated column or altering the data?
Welp 😔
Solved! Go to Solution.
*UPDATE*
I found a way to return the expected result.
I had to create 4 measures:
-The values that i want to sum
-The values i want to subtract
-Another measure with the same measure that the sum and the subtract as variables and do the positive minus the negative
-A final measure that uses the IF statement to verify the conditions.
The first and the second measure is the same, altering only the Filtering events.
The third measure is the exact same as the first two, but you put the same DAX measure in variables, create a third variable summing the positive and negative values.
*UPDATE*
I found a way to return the expected result.
I had to create 4 measures:
-The values that i want to sum
-The values i want to subtract
-Another measure with the same measure that the sum and the subtract as variables and do the positive minus the negative
-A final measure that uses the IF statement to verify the conditions.
The first and the second measure is the same, altering only the Filtering events.
The third measure is the exact same as the first two, but you put the same DAX measure in variables, create a third variable summing the positive and negative values.
Hi @PauloRicardo ,
Thank you for your feedback. If the problem has been resolved, please mark it as the correct solution, and point out if the problem persists.
Best Regards,
Adamk Kong
Hi @PauloRicardo ,
Maybe you can try formula like below to create measure:
measure_ =
VAR POSITIVE =
CALCULATE (
SUMX ( 'Table', [Sum Events] ),
FILTER (
VALUES ( 'Table'[COD_EVENTS] ),
'Table'[COD_EVENTS]
IN {260, 261}
)
)
VAR NEGATIVE =
CALCULATE (
SUMX ( 'Table', [Sum Events] ),
FILTER (
VALUES ( 'Table'[COD_EVENTS] ),
'Table'[COD_EVENTS] IN { 730 }
)
)
VAR SUMM = POSITIVE - NEGATIVE
VAR RESULT = IF(SUMM < 0, 0, SUMM)
VAR _Table =
SUMMARIZE(
'Table',
'Table'[REFERENCE],
"Positives", CALCULATE(SUMX('Table', [Sum Events]), 'Table'[COD_EVENTS] IN {260, 261}),
"Negatives", CALCULATE(SUMX('Table', [Sum Events]), 'Table'[COD_EVENTS] IN {730})
)
VAR _AdjustedTotal =
SUMX(
_Table,
IF([Positives] - [Negatives] < 0, 0, [Positives] - [Negatives])
)
RETURN
IF(HASONEVALUE('Table'[REFERENCE]), RESULT, _AdjustedTotal)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
112 | |
105 | |
98 | |
38 | |
30 |