Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hi, I am struggling to come up with a DAX solution to compute the differences of multiple selected forecast versions.
First, I will select two forecast versions on my slicers, which will be shown across 12 months in a table.
Next, I want to derive the difference between the two versions by months as a comparison in the last line:
My current dataset is modelled as follows.
The column under Version contains columns consisting from Apr-24 to Mar-25 sequentially, and period runs from JAN to DEC:
Thanks and appreciate any help gathered.
Solved! Go to Solution.
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
INDEX function (DAX) - DAX | Microsoft Learn
expected result measure: =
VAR _diff =
CALCULATE (
SUM ( forecast[Value] ),
INDEX (
1,
ALLSELECTED ( forecast[Version], forecast[Version sort] ),
ORDERBY ( forecast[Version sort], ASC )
)
)
- CALCULATE (
SUM ( forecast[Value] ),
INDEX (
1,
ALLSELECTED ( forecast[Version], forecast[Version sort] ),
ORDERBY ( forecast[Version sort], DESC )
)
)
VAR _result =
CALCULATE (
SUM ( forecast[Value] ),
KEEPFILTERS ( forecast[Version] IN VALUES ( 'version'[Version] ) )
)
RETURN
IF (
HASONEVALUE ( 'version'[Version] ),
SWITCH (
TRUE (),
COUNTROWS ( VALUES ( forecast[Version] ) ) = 2, IF ( SELECTEDVALUE ( 'version'[Version] ) = "Difference", _diff, _result )
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
INDEX function (DAX) - DAX | Microsoft Learn
expected result measure: =
VAR _diff =
CALCULATE (
SUM ( forecast[Value] ),
INDEX (
1,
ALLSELECTED ( forecast[Version], forecast[Version sort] ),
ORDERBY ( forecast[Version sort], ASC )
)
)
- CALCULATE (
SUM ( forecast[Value] ),
INDEX (
1,
ALLSELECTED ( forecast[Version], forecast[Version sort] ),
ORDERBY ( forecast[Version sort], DESC )
)
)
VAR _result =
CALCULATE (
SUM ( forecast[Value] ),
KEEPFILTERS ( forecast[Version] IN VALUES ( 'version'[Version] ) )
)
RETURN
IF (
HASONEVALUE ( 'version'[Version] ),
SWITCH (
TRUE (),
COUNTROWS ( VALUES ( forecast[Version] ) ) = 2, IF ( SELECTEDVALUE ( 'version'[Version] ) = "Difference", _diff, _result )
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
100 | |
65 | |
44 | |
36 | |
36 |