Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I would like to know if it is possible to do in the same matrix what I show in the image. It is about calculating the differences between two years for different metrics, and always putting the difference between the years.
| Sales | Unit | |
| 2019 | 20 | 5 |
| 2020 | 30 | 7 |
| Difference | 10 | 2 |
The only solution I found was this one, but, maybe there is a better one.
salesDifference =
VAR _year =
SWITCH (
TRUE (),
SELECTEDVALUE ( dim_date[year] ) <> 0, "year",
BLANK ()
)
RETURN
IF ( _year = "", [salesDiff], [sales] )
----
WHERE [salesDiff] IS
salesDiff =
VAR _minsales =
CALCULATE( SUM ( fac_sales[sales] ), Filter(dim_date, dim_date[year] = Min( dim_date[year] ) ) )
VAR _maxsales = IF (
CALCULATE( SUM ( fac_sales[sales] ), Filter(dim_date, dim_date[year] = Max( dim_date[year] ) ) )
RETURN
_maxsales - _minsales
Thanks
Solved! Go to Solution.
@bestevezdyb , On of this way is use isinscope or isfiltered and move this diff to grand total
new sales = if(isinscope(Date[Year]), [sale], [diff])
or something like this
https://community.powerbi.com/t5/Desktop/Grand-Total-in-Bar-Chart/m-p/612631
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
@bestevezdyb , On of this way is use isinscope or isfiltered and move this diff to grand total
new sales = if(isinscope(Date[Year]), [sale], [diff])
or something like this
https://community.powerbi.com/t5/Desktop/Grand-Total-in-Bar-Chart/m-p/612631
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 37 | |
| 35 | |
| 34 | |
| 28 |
| User | Count |
|---|---|
| 134 | |
| 101 | |
| 71 | |
| 67 | |
| 65 |