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

get a column calculating the ratio of a category

I have table like this 

Project                Category                           Value
A                    BUZ                         2
A                    JUZ                         8
A                    JUZA                         7
A                    OUZ1                         21
B                    KJUZ                         12
B                    JUZ                         211

 

I need to calculate ratio for each category So for example for Project A Category BUZ ratio will be (2/(2+8+7+21)) and for category JUZ it will be (8/(2+8+7+21))

 

For Project B it will be 12/(12+211) for category KJUZ.

 

Project                Category                           ValueRatio
A                    BUZ                         20.0526
A                    JUZ                         80.2105
A                    JUZA                         70.184
A                    OUZ1                         210.55263
B                    KJUZ                         120.053811
B                    JUZ                         2110.946

 

How can I get it? I need to have it as a column in my Power Bi table.

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @zzzsharepoint 

try to create a new column with this

ValueRatio =
VAR ProjectValue =
CALCULATE(
    SUM(TableName[Value]),
    ALLEXCEPT(TableName, TableName[Project])
)
RETURN FORMAT(DIVIDE(TableName[Value], ProjectValue), "0.0%")
 
I tried and it worked like this:
FreemanZ_0-1670421875396.png

 

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @zzzsharepoint 

try to create a new column with this

ValueRatio =
VAR ProjectValue =
CALCULATE(
    SUM(TableName[Value]),
    ALLEXCEPT(TableName, TableName[Project])
)
RETURN FORMAT(DIVIDE(TableName[Value], ProjectValue), "0.0%")
 
I tried and it worked like this:
FreemanZ_0-1670421875396.png

 

Uspace87
Resolver III
Resolver III

@zzzsharepoint 

 

Hi, 

 

You can create the following measures:

1) Total by project = CALCULATE( SUM('Table'[Value]),REMOVEFILTERS('Table'[Category]))
2) 
Ratio = DIVIDE(SUM('Table'[Value]),[Total by project])

 

 

 

Uspace87_0-1670421165725.png

 

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.