March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |