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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
v-binbinyu-msft
Community Support
Community Support

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
v-binbinyu-msft
Community Support
Community Support

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.