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
chayanupadhyay
Helper III
Helper III

Calculating Ratio as per category for each project

Hi All,

 

I need to calculte ratio of each category for every project, PFB the sample data:

 

ProjIDCategory
1A
1B
1A
2A
2B

 

So the ratio for project 1 for both the category is 66:33  since A will be 2/3  and B will be 1/3

for Proj 2 the ratio will be 50:50

 

I need to use this ratio for other calculation so we need to store this ration in below table:

 

Proj IDA RatioB Ratio
1  
2  

 

both tables are join on Proj ID column.

 

Please let me know if you need more clarification on above scenario.

Thank you for the help and support.

 

Regards,

Chayan Upadhyay

 

2 REPLIES 2
TeigeGao
Solution Sage
Solution Sage

Hi @chayanupadhyay ,

Please refer to the following DAX query: 

Measure =
VAR a =
    DIVIDE (
        COUNTROWS ( 'Table' ),
        CALCULATE ( COUNTROWS ( 'Table' ), ALL ( 'Table'[Category] ) )
    )
RETURN
    FLOOR ( a * 100, 1 ) & ":"
        & FLOOR ( ( 1 - a ) * 100, 1 )

The result will like: 

PBIDesktop_hcfx7yFyXJ.png

Best Regards,

Teige

Thank you @TeigeGao 🙂

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.