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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
TR_Belgium
Frequent Visitor

Count with slicers from 2 tables

Table A Table B
Product code Product code
SAP Id Category A
Brand Category B
  Category C

 

I have above 2 tables.

Both tables are linked via a one-to-one relationship based on column [Product code]

 

I want a table visual, with a column [SAP Id].

And, there should be a subtotal count of the number of [SAP Ids] in that visual.

This should be the result:

 

SAP IdCount
A4
B4
C4
D4

 

The [SAP Ids] and the count should be updated based on the slicers I select from table A and table B.

Problem is that, currently, if I select a slicer from table B, the count is corrected, but the column [SAP Id] still shows all of the SAP Ids, not considering the filter from table B:

This is the (incorrect) result I'm getting:

SAP IdCount
A3
B3
C3
D3

 

But, I want a visual as follows (because D is filtered out because of the filter from table B).

 

SAP IdCount
A3
B3
C3
2 REPLIES 2
bhanu_gautam
Super User
Super User

@TR_Belgium , First create a combined table either by using Merge in Power Query or by DAX

Go to model new table

CombinedTable =
NATURALINNERJOIN(
SELECTCOLUMNS(TableA, "Product code", TableA[Product code], "SAP Id", TableA[SAP Id], "Brand", TableA[Brand]),
SELECTCOLUMNS(TableB, "Product code", TableB[Product code], "Category A", TableB[Category A], "Category B", TableB[Category B], "Category C", TableB[Category C])

 

Then create measure

 

   SAPIdCount = COUNTROWS(CombinedTable)


)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks for the answer, would you know if it is also possible to have a solution without merging tables?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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