cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
monk
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
v-janeyg-msft
Community Support
Community Support

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

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. !!

lbendlin
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
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

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.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Kudoed Authors