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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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, @Anonymous 

 

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, @Anonymous 

 

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, @Anonymous 

 

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.

Hi, @Anonymous 

 

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.

Anonymous
Not applicable

@v-janeyg-msft Thank you. !!

lbendlin
Super User
Super User

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors