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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Best way to calculate percent error based on two different rows

I have a table that consists of multiple rows of pressure readings for multiple different types of devices. One of the devices is a reference device. Each pressure reading for all devices, including the reference, is associated with a pointid. For example:

 

PointIDModelPressure Reading
1A5
1B4
1Reference6
2A1
2B2
2C6
2Reference5

 

 

I need to get the percent error for each pressure reading, where percent error is defined as:

(pressure reading - reference pressure)  / reference pressure * 100. For example, the percent error for the first row would be 5 -6 / 6 *100 = -16.67 percent.

 

What is the best way to search for the associated reference pressure for each row? My initial thought is to, in power query, duplicate the pressure table, and filter out all rows except the reference pressure. This is my reference pressure table. Then to create a calculated column in the original table, where I go through each row and do a lookup for the reference pressure with the same point id. Is there a better way to go about this?

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

A new column =

var _ref = maxx(filter(Table, [PointID] = earlier( [PointID] ) && [Model] ="Reference"  ) , [Pressure Reading] )

return

divide([Pressure Reading] -_ref, _ref) *100 

Divide(

Anonymous
Not applicable

Sorry, I am not quite following this. Are you suggesting a place this code in the customn column window, or in the advanced editor? If in the custom column window, I get a token eof expected error when I attempt to define a variable as you have done.

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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