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

Create a measure of the ratio of value in same column by different groups in different columns

 

I have below data. 

 

Items 1-5 were sold and the cost of them are splitted with below ratio by categories and brands.  The last 2 columns are the working steps and the values are look up from Table 2 & 3 with calculated formula set.  Cost Split (in USD) is the total cost * cost split ratio * exchange rate.

 

I wanna create a measure in Power BI which calculates the ratio of cost split by brands and cost split by categories, i.e. sum of total cost split by brands / sum of total cost split by categories, and the results will be shown in Pivot Table format (Table 4).  For example,  the ratio of Brand E in Cat A is 6 / 11 = 54.5%.  How to set the measure to get the result in Power BI Pivot Table?

 

Table 1 Cost Split of Item Sold

ItemCategoryBrandCost Split RatioCurrencyCost Split (in USD)
Item 1Cat ABrand D0.50HKD5.00
Item 1Cat ABrand E0.30HKD3.00
Item 1Cat BBrand F0.20HKD2.00
Item 2Cat BBrand F0.40JPY4.80
Item 2Cat CBrand D0.60JPY7.20
Item 3Cat ABrand E0.20USD3.00
Item 3Cat CBrand F0.10USD1.50
Item 3Cat BBrand D0.70USD10.50
Item 4Cat CBrand E0.20CNY1.60
Item 4Cat BBrand E0.80CNY6.40
Item 5Cat CBrand F1.00KRW11.00

 

Table 2 Total Cost of Items Sold

ItemCurrencyCost
Item 1HKD77.7
Item 2JPY1262.52
Item 3USD15
Item 4CNY55.6
Item 5KRW13101.77

 

Table 3 Exchange Rate

CurrencyExchange Rate
HKD7.77
USD1
CNY6.95
KRW1191.07
JPY105.21

 

Table 4

 Cat ACat BCat C
Brand D45.5%44.3%33.8%
Brand E54.5%27.0%7.5%
Brand F0.0%28.7%58.7%

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @trinachung 

Create a measure

Measure =
SUM ( Table1[cost split usd] )
    / CALCULATE (
        SUM ( Table1[cost split usd] ),
        FILTER (
            ALLSELECTED ( Table1 ),
            Table1[Category]
                = MAX ( Table1[Category] )
        )
    )

Capture8.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @trinachung 

Create a measure

Measure =
SUM ( Table1[cost split usd] )
    / CALCULATE (
        SUM ( Table1[cost split usd] ),
        FILTER (
            ALLSELECTED ( Table1 ),
            Table1[Category]
                = MAX ( Table1[Category] )
        )
    )

Capture8.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the solution, Maggie!

amitchandak
Super User
Super User

New columns in table 1

Total cost = maxx(filter(table2,table1[item]=table2[item] && table2[Currency] = table1[Currency]),table2[Cost])
exchange rate =maxx(filter(table3,table3[Currency] = table1[Currency]),table3[Exchange Rate])
Cost Split (in USD) = [Total cost] * [cost split ratio] * [exchange rate]

 

Appreciate your Kudos.

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.