Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi All,
I need to subtract two columns from same table. I'll try to explain with example :
Lets say, I have this table in which, % of costs to sales - is a calculated column.
Formula is: % of costs to sales = DIVIDE('Table'[Costs],'Table'[Sales], 0)
Department | Costs | Sales | Year | % of Costs to Sales |
a | 34090 | 3124235 | 2021-22 | 1.09% |
b | 3453 | 532522 | 2022-23 | 0.65% |
a | 2424 | 234234235 | 2021-22 | 0.00% |
b | 53462 | 24324221 | 2022-23 | 0.22% |
a | 234324 | 42345235 | 2021-22 | 0.55% |
b | 25251 | 323424 | 2021-22 | 7.81% |
When I add a matrix, it will give me:
Here, I have added year in Columns, Departments in Row and calculated % in Values.
Now, I need to calculate difference of % values between columns - 2022-23 and 2021-22.
That means-
For deartment A, I should get -1.65% in new column and
For deartment B, I shuld get -6.94%.
Can some one help me, how can I calculate this difference? Any help is much appreciated!:)
Solved! Go to Solution.
Hi @archuleta28
You can refer to the following column:
% of Costs to Sales = var a=SUMMARIZE(FILTER('Table',[Year]<>"Difference"),[Department],[Costs],[Sales],[Year])
var _current_=SUMX(FILTER(a,[Department]=EARLIER('Table'[Department])&&[Year]=MAXX(a,[Year])),DIVIDE([Costs],[Sales]))
var _last=SUMX(FILTER(a,[Department]=EARLIER('Table'[Department])&&[Year]=MINX(a,'Table'[Year])),DIVIDE([Costs],[Sales]))
return IF('Table'[Year]="Difference",_current_-_last,DIVIDE([Costs],[Sales]))
Output:
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @archuleta28
You can refer to the following column:
% of Costs to Sales = var a=SUMMARIZE(FILTER('Table',[Year]<>"Difference"),[Department],[Costs],[Sales],[Year])
var _current_=SUMX(FILTER(a,[Department]=EARLIER('Table'[Department])&&[Year]=MAXX(a,[Year])),DIVIDE([Costs],[Sales]))
var _last=SUMX(FILTER(a,[Department]=EARLIER('Table'[Department])&&[Year]=MINX(a,'Table'[Year])),DIVIDE([Costs],[Sales]))
return IF('Table'[Year]="Difference",_current_-_last,DIVIDE([Costs],[Sales]))
Output:
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi @archuleta28
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
103 | |
99 | |
98 | |
38 | |
37 |
User | Count |
---|---|
151 | |
121 | |
73 | |
71 | |
63 |