Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Solved! Go to Solution.
Hi, @Anonymous
You can try the following formula.
Projected =
Var N1=IF (
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2022
) * -1
= BLANK (),
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2021
) * -1,
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2022
) * -1
)
Return
IF(HASONEVALUE('Calendar'[Month name]),N1,SUMX(VALUES('Calendar'[Month name]),N1))
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
You can try the following formula.
Projected =
Var N1=IF (
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2022
) * -1
= BLANK (),
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2021
) * -1,
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2022
) * -1
)
Return
IF(HASONEVALUE('Calendar'[Month name]),N1,SUMX(VALUES('Calendar'[Month name]),N1))
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
please try
Projected =
SUMX (
VALUES ( 'Date'[Month Name] ),
IF (
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2022
) * -1
= BLANK (),
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2021
) * -1,
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2022
) * -1
)
)
FYI that You should consider using variables to simplify your code and improve performance (your current measure would do the same query twice is the false path). Here is an example.
Projected =
VAR CY =
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2022
) * -1
RETURN
IF (
ISBLANK ( CY ),
CALCULATE (
SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
'6. Actuals'[Actuals],
'Calendar'[Year] = 2021
) * -1,
CY
)
Also, to get the expected value in the total row, please follow the approach described in this video.
Power BI - Tales from the front #01 - Getting the Right Total - YouTube
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |