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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ZoheilSharifi
New Member

Calculate differences of values of two selected coloumns

Hello Guys,
I would like to know I can calculate the difference of the values of two selected coloumns:

The raw data is looking like that:

 

TimePressure 1Pressure 2Pressure 3Pressure 4
1344353
2643443
37548743
4454548734
5454554
654422

 

I would like to use a filter which is showing the data of two selected coloumns from the table and calculating the difference.

At the end, all the selected coloumns, and the calculated differences should be shown on a line chart. 

 

For example:
1) I am selecting with my slicer the coloumns Pressure 2 and Pressure 4.

2) PowerBI is calculating the difference of Pressure 2 and pressure 4.

3) In the line Chart the curve of Pressure 2 and Pressure 4 and Pressure(4-2) is shown.

 

It is important to have the dynamic function. So based on the selection of the user, the difference should be calculated based on the two selected values.
Hopefully it is understandable and you can help me.

Thank you very much!

 

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @ZoheilSharifi 

 

You can try the following methods.

In the Power Query, choose first column-Unpivot Other Columns:

vzhangti_0-1684222396862.png

vzhangti_1-1684222465465.png

Measure1 = CALCULATE(SUM('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Time]),[Attribute]=MIN('Table'[Attribute])))
Measure2 = CALCULATE(SUM('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Time]),[Attribute]=MAX('Table'[Attribute])))
Difference = [Measure2]-[Measure1]

vzhangti_2-1684223289396.pngvzhangti_3-1684223300979.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

FreemanZ
Super User
Super User

Thank you very much! 
I will try it within the next days and will let you know.
Teally appriciate your support :).

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.