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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Premlatapandey9
Microsoft Employee
Microsoft Employee

calculate ratio and category percent out of total

Hello Everyone I'm looking to create a DAX formula that can help me determine the distribution of different ratios between Company ID and Item ID. Specifically, I want to know how many records have a 1:1 ratio, how many have a 1:2 ratio, 1:3, and so on. Additionally, I'm interested in calculating the percentage of each category relative to the total data. For instance, I'd like to find out what percentage of the data has a 1:1 ratio, 1:5, and so forth.

Refrence Data Looks like below -

Company ID Item ID
XYZ-23456C1284765
WTQ-2345C1284765
BWT-2726C1284765
GHT-2736C1284765
MTY-2737C1284765
GHT-2345C1273783
JHT-3645C1273783
JHR-1234C1273783
LKR-2345C4857575
LJT-1235C4857575
PRT-2345C4857575

 

based on above data I will get the below 

Item IDCount of Company ID
C12847655
C12737833
C48575753

=

Avergae Ratio 
3.66

Please help me with the Dax query to achive the above result if possible any hlep in this regard is much appreciated

Thanks and Regards

@member @help @needurgenthelp

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file if it suits your requirement.

 

Jihwan_Kim_0-1698083677148.png

 

 

Count company ID and ratio = 
IF (
    HASONEVALUE ( Data[Item ID] ),
    FORMAT ( COUNTROWS ( DISTINCT ( Data[Company ID] ) ), "#,#0" ),
    FORMAT (
        AVERAGEX (
            DISTINCT ( Data[Item ID] ),
            CALCULATE ( COUNTROWS ( DISTINCT ( Data[Company ID] ) ) )
        ),
        "#,#0.00"
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Greetings, everyone! I'm in search of a solution, and I would greatly appreciate any assistance. Additionally, I'm seeking guidance on how to generate a ratio column by utilizing the counts from two columns. Can anyone offer their expertise? To provide further clarification on the requirements, I'll share another data example.

 

I have in dataI want to get through calculation
Company ID Item IDRatio coulmn Ratio %  
9987655Abc12341:04 count of 1:4 devide by total57%
8474774Abc12341:04 count of 1:03 devide by total43%
8747646Abc12341:04   
9009866Abc12341:04   
9987655xyz12341:03   
8474774xyz12341:03   
8747646xyz12341:03   

@member @help @needurgenthelp

Hello @Jihwan_Kim this provides only average, I also want to know how many records of company ID to Item ID have a 1:1 ratio, how many have a 1:2 ratio, 1:3, and so on. Additionally, I'm interested in calculating the percentage of each category relative to the total data. For instance, I'd like to find out what percentage of the data has a 1:1 ratio, 1:5, and so forth, let me know if it clarify the ask or you need more details.Thank you !

ThxAlot
Super User
Super User

ThxAlot_0-1698083398226.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.