cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Count of column values in Table 1 present in Table 2 column - Power BI

I have two tables

 

table 1

product_nameID
abc123
abc789

 

table 2

product_nameID
abc

789

 

report layout

monk_0-1608695781965.png

 

Filter table 2 ID values based on table 1 Id values

 

 

business qn: I want to know how many of them downloaded the trial product and out of those how many purchased. Left side trials, right side purchases. Table_1 is trial download data table_2 is purchase data

 

PS: columns are not unique

 

 

 

 

2 ACCEPTED SOLUTIONS
Microsoft
Microsoft

Hi, @monk 

 

It’s my pleasure to answer for you.

According to your description,I think create two measure in card to calculate the desired result.

Like this:

 

count1 = COUNTROWS(Table1)

count2 = COUNTROWS(INTERSECT(Table2,Table1))

 

4.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

Hi, @monk 

 

If there are more than two columns in the table.

You can try this:

count2 =
COUNTROWS (
    INTERSECT (
        SELECTCOLUMNS ( Table2, "name", [product_name], "id", [ID] ),
        SELECTCOLUMNS ( Table1, "name", [product_name], "id", [ID] )
    )
)

Best Regards

Janey Guo

 

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

4 REPLIES 4
Microsoft
Microsoft

Hi, @monk 

 

It’s my pleasure to answer for you.

According to your description,I think create two measure in card to calculate the desired result.

Like this:

 

count1 = COUNTROWS(Table1)

count2 = COUNTROWS(INTERSECT(Table2,Table1))

 

4.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

Hi, @monk 

 

If there are more than two columns in the table.

You can try this:

count2 =
COUNTROWS (
    INTERSECT (
        SELECTCOLUMNS ( Table2, "name", [product_name], "id", [ID] ),
        SELECTCOLUMNS ( Table1, "name", [product_name], "id", [ID] )
    )
)

Best Regards

Janey Guo

 

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

@v-janeyg-msft Thank you. !!

Super User III
Super User III

For maximum flexibility you'll want to let the data model do the work for you. Meaning you would need to define some sort of relationship between the tables, and then decide on the filter direction (which table impacts the other). This works ok-ish even if the values are not unique in the "dimension"  table but it would works better if you had a Products reference table that has unique values.

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors