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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ljr91-us
Regular Visitor

Slicer from table 1 applies to table 2 (same page) - Check and compare columns in different tables

I have following two tables:

 

In current visual, I have the [year_month] from table 1 as a slicer. I want to create a new flag column in table 2 to check if [Unit] from Table 2 exists in Table 1.

 

Raw Data:

ljr91us_0-1672364053051.png

My problems is I can get the flag column created in Table 2, but the slicer from Table 1 does not apply to table 2, even they are in the same page/view.  For example, if I select year_month slicer to "2022-12", my current output still has unit 7 and 8 flag as YES, they should be NO because slicer '2022-12' filter out records (unit 7, 8 ) from table 1.

 

my current code (add new column):   flag= IF ( Table2[unit] IN DISTINCT ( Table1[unit]), "YES", "NO" )

ljr91us_1-1672364080874.png

I removed all relationship between table 1 and table 2, because I want to display all values 1-10 in table 2, can anyone let me know how to upload the PBIX file?

ljr91us_0-1672367786862.png

 

 

 

1 ACCEPTED SOLUTION

Hi, @ljr91-us 
I create a measure (reference from amitchandak Reply)  

And there is a relationship with Table1[unit] and Table2[unit]

 

 

Measure = 
var cnt = countx(filter(Table1, SELECTEDVALUE(Table2[Unit]) = Table1[Unit]) ,Table1[Unit])

return

if(isblank(cnt), "no", "Yes")

 

 

 

 Result :

JosephWu_0-1672369782330.png

Best regards,
Joseph

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@ljr91-us , new column in table 2

 

 

new col = var_cnt = countx(filter(Table1, Table2[Unit] =Table1[Unit]) ,Table1[Unit])

return

if(isblank(_cnt), "no", "Yes")

 

refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

Hi,

 

It is the same as my current output, which is not the desired output.  

 

I want to have

1) table 2 to display all 1-10 unit 

2) having slicer filter out table 1 records, then use filtered records to compare with table 2

ljr91us_0-1672367283078.png

 

Hi, @ljr91-us 
I create a measure (reference from amitchandak Reply)  

And there is a relationship with Table1[unit] and Table2[unit]

 

 

Measure = 
var cnt = countx(filter(Table1, SELECTEDVALUE(Table2[Unit]) = Table1[Unit]) ,Table1[Unit])

return

if(isblank(cnt), "no", "Yes")

 

 

 

 Result :

JosephWu_0-1672369782330.png

Best regards,
Joseph

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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