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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to calculate percentage based on the values from two different tables?

Hi, 

 

I have two visuals (from two different tables) on my dashboard. Target and Completion. 

For example : For John the total target is 400.

 

I want to show a combined visual as such:

 

If I pick January and John the combined visual will show the following:

 

(Complete for John in January = 80) / (Total Target of John = 100 + 200 + 100) = 80/400 = 20%

 

So instead of showing 80 and 400 separately, how can I  show 20% only instead. 

 

TABLE 1  TABLE 2
PersonProductTarget  PersonMonthComplete
JohnA100  JohnJan80
JohnB200  JohnFeb100
JohnC100  JohnMar50
Mary D50  Mary Jan50
Mary E100  Mary Feb 100
Mary F100  Mary Mar70

 

 

Any help is greatly appcetiated!

 

Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Not sure if you have a Calendar Table ( if you dont, I'd definitely get one) or a table of unique Persons, but assuming you dont on this example.

 

Need to create a bridge table of the Person and Month columns:

Bridge = VALUES(Target[Person])

Bridge Month = values( 'Goal'[Month] )

Then since you want the totals to be used for each , I created another table using summarize:

Total Target =
SUMMARIZE (
    Target,
    Target[Person],
    "Total Target", CALCULATE ( SUM ( Target[Target] ) )
)

And make the relationships below, so our data model looks like:

Data Model.png

Now we can write the following measures:

Total Goal = sum ( 'Goal'[Complete] )

Sum Total Target = SUM ( 'Total Target'[Total Target] )

% Complete = DIVIDE([Total Goal],[Sum Total Target] )

Then using the Person and Month from the bridge tables as filters we get the following:

Final Table.png

 

Things would be much easier if you have a Calendar and Person tables instead of these bridge tables. Also could do some of this in Power Query to cut down on the heavy lifting DAX has to do, but didnt explain here, but I can if you want.  

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Not sure if you have a Calendar Table ( if you dont, I'd definitely get one) or a table of unique Persons, but assuming you dont on this example.

 

Need to create a bridge table of the Person and Month columns:

Bridge = VALUES(Target[Person])

Bridge Month = values( 'Goal'[Month] )

Then since you want the totals to be used for each , I created another table using summarize:

Total Target =
SUMMARIZE (
    Target,
    Target[Person],
    "Total Target", CALCULATE ( SUM ( Target[Target] ) )
)

And make the relationships below, so our data model looks like:

Data Model.png

Now we can write the following measures:

Total Goal = sum ( 'Goal'[Complete] )

Sum Total Target = SUM ( 'Total Target'[Total Target] )

% Complete = DIVIDE([Total Goal],[Sum Total Target] )

Then using the Person and Month from the bridge tables as filters we get the following:

Final Table.png

 

Things would be much easier if you have a Calendar and Person tables instead of these bridge tables. Also could do some of this in Power Query to cut down on the heavy lifting DAX has to do, but didnt explain here, but I can if you want.  

Anonymous
Not applicable

Hi Nick, 

 

Thank you for your answer. 

 

I believe I have those unique tables. I have a date dimension table where I have year-month-week etc. and a separate table for persons. 

 

And two more tables for the views that I shared with you from before. 

 

In this case what can I do to get the percentages?

 

Thanks again!!

Anonymous
Not applicable

No need to do the bridge steps then. Just sub in your Date and Persons tables instead.  Then be sure to use fields from those tables as filters.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.