Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
HEW
Helper III
Helper III

Difference between 2 columns in a Matrix Table

Hi.

 

I am trying to calculate the difference between 2 columns i Desktop.

The value is a measure and the  columns are one field, pls. see below.

I have tried to create a measure but with no luck. 

For January the new column should be -15

February -12

......

July +38

 

Any suggestions?

Thanks a lot.Diff.PNG

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

 

If there is also a Date column available in your dataset, then you should create a relatiosnhip between this Date column and the Date column of your Calendar Table.  In the Calendar Table, write the following calculated column formulas to extract the Year and Month

 

Year=year(Calendar[Date])

Month=FORMAT(Calendar[Date],"mmmm")

 

In your visual, drag Year and Month from the Calendar Table.  Then write this measure

 

[Proposals Count]-CALCULATE([Proposals Count],SAMEPERIODLASTYEAR(Calendar[Date]))

 

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish.

 

It works perfectly! Would it be possible to leave out the difference for 2017 as it is the same value as the count?

 

Br. HeleDiff 2.PNG

Hi,

 

I don't think that is possible.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-frfei-msft
Community Support
Community Support

Hi @HEW,

 

Please refer to this case to find the solution.

 

https://community.powerbi.com/t5/Desktop/Difference-between-2-columns-in-a-Matrix-Table/td-p/81614/p...

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi Frank.

 

Is it really so complicated? I'll try and adapt the formula to my data and hope it works Smiley Happy Thanks.

 

Br. Helen

Hi @HEW,

 

I made one sample for your reference.

 

1. Enter the data as your description and create a calculated table.

 

Table = SUMMARIZE(Table1,Table1[Month],Table1[mo],Table1[Year],"sum",SUM(Table1[Amount]))

2. Create a calculated column in Table.

diff = var prevalue = CALCULATE(FIRSTNONBLANK('Table'[sum],1),
FILTER('Table',('Table'[Year]= (EARLIER('Table'[Year])-1)) && 'Table'[mo]= EARLIER('Table'[mo])))
return
IF(ISBLANK(prevalue), BLANK(),'Table'[sum]-prevalue)

3. Then we can get the result as we excepted.

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hi @HEW,

Why cant you show the Year on Year measure next to 2018 column in the table?

 

Regards

Lokesh

I'm not sure I know what you mean.... pls. elaborate Smiley Happy

Anonymous
Not applicable

Hi @HEW,

i mean to say that why cant you use the Year over Year Change measure in the table next to 2018?

 

yoy.JPG

I have tried to add a quick measure as you suggest but it only returns 0,-. But thanks!

Br. Helen

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.