OwenAuger
Super User
5 years agoStatus:
New
Calculation Groups - incorrect result when applying via CALCULATE under certain conditions
Under certain conditions, when applying a Calculation Item using the CALCULATE function, then performing an operation on the result (such as an arithmetic operation), incorrect values are returned.
Specifically, the issue appears to arise when:
- A Calculation Item returning a Double type is applied via CALCULATE to a measure returning an Integer type (or vice versa)
- An operation is performed on the result of the CALCULATE function (such as adding/subtracting a value).
I have attached a PBIX file demonstrating the issue.
Measures 1B & 2B return incorrect values, as described below:
Scenario 1:
- Create a measure Zero Integer which returns a constant value zero of type Integer:
Zero Integer =
CONVERT ( 0, INTEGER ) - Create a Calculation Group called MyCalcGroup with a Calculation Item called One Double defined as:
CONVERT ( 1, DOUBLE ) - Create a measure that applies the One Double Calculation Item to the measure Zero Integer using CALCULATE:
1A. Underlying Measure=0 (Integer) | Calculation Item=1 (Double) =This measure returns 1 as expected.
CALCULATE ( [Zero Integer], MyCalcGroup[MyCalcItem] = "One Double" ) - Create an otherwise identical measure with zero added:
This measure returns a value of approximately 4.6E+18, not as expected.1B. Underlying Measure=0 (Integer) | Calculation Item=1 (Double) | Add Zero =CALCULATE ( [Zero Integer], MyCalcGroup[MyCalcItem] = "One Double" ) + 0
Scenario 2:
- Create a measure Zero Double which returns a constant value zero of type Double:
Zero Double =
CONVERT ( 0, DOUBLE ) - Create a Calculation Group called MyCalcGroup with a Calculation Item called One Integer defined as:
CONVERT ( 1, INTEGER ) - Create a measure that applies the One Integer Calculation Item to the measure Zero Double using CALCULATE:
2A. Underlying Measure=0 (Double) | Calculation Item=1 (Integer) =This measure returns 1 as expected.
CALCULATE ( [Zero Double], MyCalcGroup[MyCalcItem] = "One Integer" ) - Create an otherwise identical measure with zero added:
This measure returns a value of 0, not as expected.2B. Underlying Measure=0 (Double) | Calculation Item=1 (Integer) | Add Zero =CALCULATE ( [Zero Double], MyCalcGroup[MyCalcItem] = "One Integer" ) + 0
This forum post discussed a particular instance of this issue.
Regards,
Owen Auger
2 Comments
- OwenAuger
Super User
This issue appears to be resolved as of the February 2021 Power BI Desktop update 🙂
- v-chuncz-msft
Community Support