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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Gary_RH
Frequent Visitor

Finding percentage of number using columns from different tables.

Hi,

 

Very new user here so apologies in advance, I've done several searches but I'm struggling. Maybe it's my terminology, any help would be appreciated.

 

I have a tables that have a relationship by a reference number, one table has a column that shows the starting value (which varies for each reference) which I would like to compare another column against which is the final value of that original number.

 

How would I get a gauge, for example, to display the remaining % of the initial starting value for each reference if I was to select a reference in another visual, like a slicer or bar chart for example.

 

For context, the starting value is the thickness of a piece of steel, the final value is the thickness of the steel following corrosion of that steel. Each starting value varies slightly.

 

Gary_RH_0-1650816233466.png

Table 1 with starting values

 

Gary_RH_1-1650816308092.png

Table 2 with final values

Any help would be greatly appreciated, thank you in advance.

 

Gary

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

Hi,

I've been thinking about best way to model this. Various ways to go but I think I'd do the following...

 

1) Create a relationship between the location id's. Table 1 becomes a location dimension and table 2 is a measurements fact table. There should be a 1 to many relationship between them.

 

2) I then think the easiest thing to do is create a "Latest measurement" calculated column on table 1 with the following DAX:

Latest Measurement = 
	CALCULATE ( 
		MIN 'Table 2'[Measured-Thickness] 
		)

The CALCULATE is needed as it forces "context transition", it moves the current row into the filter context so you only get the related minimum thickness.
Once you have that you can then use a measure like you've already written. (Normally you want to minimise the use of calculated columns but this seems to be a reasonable option here).



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

7 REPLIES 7
bcdobbs
Community Champion
Community Champion

Hi,

I've been thinking about best way to model this. Various ways to go but I think I'd do the following...

 

1) Create a relationship between the location id's. Table 1 becomes a location dimension and table 2 is a measurements fact table. There should be a 1 to many relationship between them.

 

2) I then think the easiest thing to do is create a "Latest measurement" calculated column on table 1 with the following DAX:

Latest Measurement = 
	CALCULATE ( 
		MIN 'Table 2'[Measured-Thickness] 
		)

The CALCULATE is needed as it forces "context transition", it moves the current row into the filter context so you only get the related minimum thickness.
Once you have that you can then use a measure like you've already written. (Normally you want to minimise the use of calculated columns but this seems to be a reasonable option here).



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Gary_RH
Frequent Visitor

Well....I think I'm close.

It works well where there has only be 1 test per location as shown

Gary_RH_1-1650828877273.png

 

 

However, where there is more than one test per location it seems to summerise the %age value (as shown), how would I go about just making sure it only shows the lowest value?

 

Gary_RH_0-1650828765723.png

 

 

Thank you 🙂

Gary_RH
Frequent Visitor

I think I've solved it...?

 

 

%age difference = DIVIDE(SUM('Table-2'[Measured-Thickness]), SUM('Table-1'[Specified-Thickness (mm)]))

 

 
then format as percentage..
bcdobbs
Community Champion
Community Champion

That would certainly give you a percentage! I was about to ask exactly what sort of final output you wanted. Eg an overall value or something more specific to a particular location displayed in a matrix.

 

Only issue i can see with the measure you've written is that if you used it in a visual not filtered to a specific day it would be taking all the repeated measurements into account. If you can share what output you need I'll happily write something tomorrow for you. (Equally though what you have might be fine!)



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Thanks for the reply. I'm basically after a card to display the remaning %age of steel remaining as shown in the image below (my later post). I got it part working by replacing the DIVIDE(SUM..... to DIVIDE(MIN.... and that seems now to dispaly the MIN value for a particular location, so if there were 2 readings it would show the MIN value, not the latest. 

 

One problem I'm having is when nothing is seleceted both the gauge and the card seem to show a random value. 

 

I'm currently doing my best to learn Power BI, but I've come to realise the magic is in the DAX...which is my next challange once I've mastered the basics of the software.

bcdobbs
Community Champion
Community Champion

In Table 2 do you have a date column as well? You seem to have multiple measurements per location?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Hi @bcdobbs, yes I do, tests taken in the same location on different dates

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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