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
James_Ma
Helper I
Helper I

Create a calcualtion based on a column fro another table

Hi ,

 

I am struggling to build calculation that calculates 2 different values depending on which value is in another column from another table.

 

The example table shows % CAT INA and % MT INA and an invoice Gross total. The idea is ot have an additional column to work out the % of the gross total, depending on which category (from the case table) the case is.

current xlxs file used for data with Category column from the case table and Invoice from the invocie tablecurrent xlxs file used for data with Category column from the case table and Invoice from the invocie table

 In an ideal world I would like to see the table content as shown in the below (excel) table.

NameCategory
      
  
 

 

 
 

 

  
 

 

 
 
Count of CaseID
Sum of %age CAT Hourly CAT Sum of %age MT  Hourly MT Invoice TotalExpected result 
Manager 1CAT940%£37.5035%£35.00£102,048.90£40,819.56CAT % * Invoice total
Manager 1MT8140%£37.5035%£35.00£598,368.04£209,428.81MT % * Invoice total
Manager 2CAT4045%£41.3945%£42.28£610,521.62£274,734.73CAT % * Invoice total
Manager 2MT5545%£41.3945%£42.28£691,696.36£311,263.36MT % * Invoice total
Manager 3CAT2040%£40.0040%£40.00£382,477.08£152,990.83CAT % * Invoice total
Manager 3MT5840%£40.0040%£40.00£621,870.37£248,748.15MT % * Invoice total
Manager 4CAT107%£42.287%£42.28£772,153.77£54,050.76CAT % * Invoice total
Manager 4MT37%£42.287%£42.28£10,715.69£750.10MT % * Invoice total
Manager 5CAT342%£45.0040%£45.00£69,779.26£29,307.29CAT % * Invoice total
Manager 5MT2242%£45.0040%£45.00£190,326.63£76,130.65MT % * Invoice total
Manager 6CAT3355%£60.0050%£50.00£662,207.63£364,214.20CAT % * Invoice total
Manager 6MT7555%£60.0050%£50.00£703,763.96£351,881.98MT % * Invoice total
Manager 7CAT3450%£48.6045%£37.49£652,758.78£326,379.39CAT % * Invoice total
Manager 7MT3750%£48.6045%£37.49£323,699.96£145,664.98MT % * Invoice total
Manager 8CAT2950%£47.0045%£57.00£562,362.24£281,181.12CAT % * Invoice total
Manager 8MT4050%£47.0045%£57.00£363,363.61£163,513.62MT % * Invoice total
Manager 9CAT9855%£53.0050%£45.00£2,450,060.27£1,347,533.15CAT % * Invoice total
Manager 9MT7555%£53.0050%£45.00£885,702.17£442,851.09MT % * Invoice total
Manager 10CAT5752%£53.0047%£43.00£1,343,946.74£698,852.30CAT % * Invoice total
Manager 10MT8252%£53.0047%£43.00£802,398.41£377,127.25MT % * Invoice total
1 ACCEPTED SOLUTION
speedramps
Super User
Super User

Try this

Answer = 
VAR mycategory = SELECTEDVALUE(yourtable[Category])
RETURN
SWITCH(
    mycategory,
"CAT",SUM(yourtable[Sum of %age CAT]) * SUM(yourtable[Invoice Total]),
"MT",SUM(yourtable[Sum of %age MT]) * SUM(yourtable[Invoice Total])
)

speedramps_0-1706210406772.png

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

View solution in original post

1 REPLY 1
speedramps
Super User
Super User

Try this

Answer = 
VAR mycategory = SELECTEDVALUE(yourtable[Category])
RETURN
SWITCH(
    mycategory,
"CAT",SUM(yourtable[Sum of %age CAT]) * SUM(yourtable[Invoice Total]),
"MT",SUM(yourtable[Sum of %age MT]) * SUM(yourtable[Invoice Total])
)

speedramps_0-1706210406772.png

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

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.