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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ksahil16
Frequent Visitor

Interesection of two tables

I have a table which I have copied twice. In these tables I have a specific date column which I want to use for comparing the rows in the two tables. There is a column Index which is a one to one match for both the columns.

 

To consider an example:

This is a table visual that I created from the original table after selecting the year 2019 (Assume that there is one more column in the original table with year which we have not selected in the table visual)

 

IndexValue1Value2Value3Value4
1AGermany 22.6computers
2BFrance34.9computers
3CEngland11.89computers
4DUSA55.88computers

 

 

Here is an example of the table visual I get after selecting Year 2020 from the other table:

 

IndexValue1Value2Value3Value4
1AGermany 22.6computers
2BFrance34.9computers
3CEngland11.89computers
5FPoland46.77tables

 

 

I want to disply a table which shows the rows which were new in table 2 in which I had selected 2020, so as to alert that there was a new combination in 2020 which was not present in 2019. 

 

IndexValue1Value2Value3Value4
5DPoland46.77computers

 

NOTE: I would want to consider all the combinations of the columns Value1 and so on. One approach that I was thinking was to check for the new indexes present and display them. But I am not able to understand how do I disply the tnire new table with all the new values in 2020.

I even tried a measure: 

RowsNotPresentInRelationAssociation2 =
VAR NewValues = EXCEPT( VALUES('relation_association_2'[UniqueColumn]), VALUES('relation_association'[UniqueColumn]) ) RETURN IF( COUNTROWS(NewValues) > 0, NewValues, "No new values found" )

Here when there are new values, how do I display them ( the entire table visual that I created above)

1 ACCEPTED SOLUTION

Hi, @ksahil16 

 

You can try the following methods.

Measure = 
Var _table=EXCEPT(VALUES(Table2[Index]),VALUES(Table1[Index]))
Return
IF(SELECTEDVALUE(Table2[Index]) in _table,1,0)

Place this measure in the 2020 table filters and set equal to 1.

vzhangti_0-1697095751632.png

Is this the result you expect? Please see the attached document.

 

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
Greg_Deckler
Super User
Super User

@ksahil16 So generally you could create a complex selector for this. Something like the following and then you can filter Measure for 1.

 

Measure = 
    VAR __Except = EXCEPT( 'Table2', 'Table' )
    VAR __Result = IF( COUNTROWS( __Except ) > 0, 1, 0)
RETURN
    __Result

 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thank you for the reply. I get the logic but as the logic you have applied, if the countrows is greater than 0, it returns 1 and not the entire row which is different. I want to display the entire row information. In the example above :

IndexValue1Value2Value3Value4
5DPoland46.77computer

Hi, @ksahil16 

 

You can try the following methods.

Measure = 
Var _table=EXCEPT(VALUES(Table2[Index]),VALUES(Table1[Index]))
Return
IF(SELECTEDVALUE(Table2[Index]) in _table,1,0)

Place this measure in the 2020 table filters and set equal to 1.

vzhangti_0-1697095751632.png

Is this the result you expect? Please see the attached document.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.