Forum Discussion
Display original values and their difference in the same table
Hi,
I would like to have something like this displayed in a table in PowerBI. I have the Year values (the original ones) and I want to make the difference between them.
The catch is that every month I need to make a new difference (like using a filter), but have it all displayed in a table. Is this even possible?
| Company | Year | Value |
| A | 2019 jan | 20 |
| A | 2018 jan | 5 |
| A | difference | 15 |
| B | 2019 jan | 16 |
| B | 2018 jan | 6 |
| B | difference | 10 |
- Anonymous6 years ago
Hi Anonymous ,
I just created a sample pbix file, please check check whether that is what you want.
Table 2 = UNION(VALUES('Table'[Date]),ROW("Date","difference between 2020 and 2019"))Measure = var _curYear= CALCULATE(SUM('Table'[Number of accidents]),FILTER('Table','Table'[Company name]=MAX('Table'[Company name])&&'Table'[Date]=MAX('Table'[Date]))) var _preYear=CALCULATE(SUM('Table'[Number of accidents]),FILTER('Table','Table'[Company name]=MAX('Table'[Company name])&&'Table'[Date]=MIN('Table'[Date]))) return switch(SELECTEDVALUE('Table 2'[Date]),"difference between 2020 and 2019",_curYear-_preYear, CALCULATE(SUM('Table'[Number of accidents]),FILTER('Table','Table'[Company name]=MAX('Table'[Company name]))))Best Regards
Rena
7 Replies
- amitchandak
Super User
Anonymous , assume you have only two months, you have to create a new table and join it with the first table
summarize( Table,table[Company], "Year",0, "Month ", [This Month] -[lastMonth])
DAx Join https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/
Month wise diff
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
- AnonymousNot applicable
Hi Anonymous ,
You can refer the contents in the following links to achieve it:
Using SAMEPERIODLASTYEAR To Compare The Difference Between This Year & Last Year
Calculating the difference between a specific month, and the following months
Best Regards
Rena
- AnonymousNot applicableThanks to you both. I've managed to get the difference between the months I wanted (selected by a filter), but I can't display that in the format I need, since the original values are in a column and the difference in a measure format. Is it possible to achieve that? I mean like this the table I posted above?
- AnonymousNot applicable
Hi Anonymous ,
What's your expected result? Could you please just make examples to explain? Then we can provide you a proper solution. Thank you.
Best Regards
Rena