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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ditka78
Frequent Visitor

Need to get a visual that shows the ratio of matching rows from 2 different tables

I feel like this is a lot easier than I'm making it, but everything I try gives different results and I'm not sure what I'm doing wrong.

I have two tables Incidents and Agency Number Reference.

The Incident table has Incident tickets listed by the user they were opened for.  I have also merged it so the table has a column indicating an agency number the user is with. So for example:

User IDIncident NumberAgency Number
12345INC123A123
67890INC456A456

The Agency Number Reference has all agents listed by their agency number so for example:

User IDAgency Number
12345A123
67890

A456

13579A123

Not all users will have an entry on the Incident table.
I am trying to generate a visual that will allow me to show the Ratio of entries matching each agency number from each table.  So it would show (Incs in A123)/(Agents in A123).  So for the sample data above it would give me a bar graph showing a value of .5 for a123 and 1 for A456. 

I had a similar problem, where I was looking at the operating system used,that I solved by making a measure for each possible value of the common column that gave the count matching, 

Android Device Count = COUNTROWS(CALCULATETABLE('Devices','Devices'[OS]="Android"))

but that isn't practical here as there are hundreds of different values for the Agency Number.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ditka78 ,

Please try below steps:

1. create a measure with below dax formula

Measure =
VAR cur_an =
    SELECTEDVALUE ( 'Agency Number Reference'[Agency Number] )
VAR tmp1 =
    FILTER (
        ALL ( 'Agency Number Reference' ),
        'Agency Number Reference'[Agency Number] = cur_an
    )
VAR tmp2 =
    FILTER ( ALL ( Incident ), Incident[Agency Number] = cur_an )
RETURN
    DIVIDE ( COUNTROWS ( tmp2 ), COUNTROWS ( tmp1 ) )

2. add a cluster column chart with field and measure 

vbinbinyumsft_0-1673330194991.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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
Anonymous
Not applicable

Hi @ditka78 ,

Please try below steps:

1. create a measure with below dax formula

Measure =
VAR cur_an =
    SELECTEDVALUE ( 'Agency Number Reference'[Agency Number] )
VAR tmp1 =
    FILTER (
        ALL ( 'Agency Number Reference' ),
        'Agency Number Reference'[Agency Number] = cur_an
    )
VAR tmp2 =
    FILTER ( ALL ( Incident ), Incident[Agency Number] = cur_an )
RETURN
    DIVIDE ( COUNTROWS ( tmp2 ), COUNTROWS ( tmp1 ) )

2. add a cluster column chart with field and measure 

vbinbinyumsft_0-1673330194991.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you, I had tried basically this, but the Selectedvalue was the function that I was missing to iterate for each agency number.  This is working for what I needed.

Manoj_Nair
Solution Supplier
Solution Supplier

@ditka78 - pls try this DAX M1, screen shoot below, you can see the ratio calculated in M2

image.jpg

If this post helps you to find solution would be happy if you could mark my post as a solution and give it a thumbs up

 

Best regards

Manoj Nair

Linkedin - https://www.linkedin.com/in/manoj-nair-%E2%98%81-344666104/

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors