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
Anonymous
Not applicable

Comparing two tables that has blank values

Table1

Venue CodeVenue NameCustomer Code
LagunaSuria101Suria
LagunaSuria102Suria
LagunaSuria103Suria
LagunaSuria104Suria
LagunaSuriaGENSURIA
LagunaSuriaGENSURIA
LagunaSuria105Suria
LagunaSuria106Suria
LagunaSuria107Suria

 

Table2

Venue CodeVenue NameCustomer Code
LagunaSuria101Suria
LagunaSuria102Suria
LagunaSuria103Suria
LagunaSuria104Suria
LagunaSuriaGENSURIA
LagunaSuriaGENSURIA
LagunaSuria 
LagunaSuria 
LagunaSuria 

 

 

Filter = 
IF (
CONTAINS (
Table1,
Table1[Venue Code], MAX ( Table2[Venue Code] ),
Table1[Customer Code], MAX ( Table2[Customer Code] )
),
1,
0
)

 

Iver199_0-1639099749818.png

 

Above is the visual before I use the measure as a filter. So what I will do now is drag the measure into the filter pane and put it as "is 0" in order to show the venue that has a difference. In this case I am expecting Laguna to show up after I apply the filter since there is obviously a difference between the two tables.

 

But after I apply the filter it shows up as blank like this. 

Iver199_1-1639099749750.png

 

I think it has something to do with the blank rows in Customer Code in Table2 because after putting in "null" instead of leaving those rows empty it actually showed up in the visual. Is there any way I can achieve the same thing while keeping those rows empty?

 

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION
edhans
Super User
Super User

I would take a different approach. Use the Model in Power BI for this. It returns this:

edhans_0-1639101954268.png

I set up a model using the Venue codes from both tables:

edhans_1-1639102019322.png

That lets me do this:

edhans_2-1639102073694.png

I have 3 measures:

Table 1 Records = COUNTROWs('table')

Table 2 Records = 
CALCULATE(
    COUNTROWS('Table 2'),
    NOT ISBLANK('Table 2'[Customer Code])
)

Difference = [Table 1 Records] - [Table 2 Records]

The difference measure goes in the filter pane and is not zero.

 

My file is here. Try to use Power BI the way it is intended - it expects a Star Schema, not a a SQL database where you are running queries on disconnected tables.


Microsoft Guidance on Importance of Star Schema

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
edhans
Super User
Super User

I would take a different approach. Use the Model in Power BI for this. It returns this:

edhans_0-1639101954268.png

I set up a model using the Venue codes from both tables:

edhans_1-1639102019322.png

That lets me do this:

edhans_2-1639102073694.png

I have 3 measures:

Table 1 Records = COUNTROWs('table')

Table 2 Records = 
CALCULATE(
    COUNTROWS('Table 2'),
    NOT ISBLANK('Table 2'[Customer Code])
)

Difference = [Table 1 Records] - [Table 2 Records]

The difference measure goes in the filter pane and is not zero.

 

My file is here. Try to use Power BI the way it is intended - it expects a Star Schema, not a a SQL database where you are running queries on disconnected tables.


Microsoft Guidance on Importance of Star Schema

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

I'm still very very new to power bi so I guess I'm susceptible to making mistakes like these. But thank you so much for the very helpful and detailed response!

Glad I could help. That is why I posted the link to the importance of a Star Schema and the details. Keep studying, and post back to the forum with any questions. Hope the rest of your project goes well @Anonymous !



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hey there! Sorry to bother you again but I was trying to use your solution to achieve something else but I was having difficulties so I figured I should ask you again.

 

I added some new rows to the tables to make it a bit easier to understand. 

Table1

Venue CodeVenue NameCustomer Code
LagunaSuria101Suria
LagunaSuria102Suria
LagunaSuria103Suria
LagunaSuria104Suria
LagunaSuriaGENSURIA
LagunaSuriaGENSURIA
LagunaSuria105Suria
LagunaSuria106Suria
LagunaSuria107Suria
BahamasSunwayBah123
BahamasSunwayBah124
BahamasSunwayBah125

 

Table2

Venue CodeVenue NameCustomer Code
LagunaSuria101Suria
LagunaSuria102Suria
LagunaSuria103Suria
LagunaSuria104Suria
LagunaSuriaGENSURIA
LagunaSuriaGENSURIA
LagunaSuria 
LagunaSuria 
LagunaSuria 
BahamasSunwayBah123
BahamasSunwayBah124
BahamasSunwayBah125

 

I implemented a slicer with your solution which has three options "Difference", "Common", "All". So now I will have two card visuals which will display the count of customer code for each of the tables. If the slicer is selected at "All" then the card visual for table 1 will show 12 while the card visual for table 2 will show 9. If "Difference" is selected at the slicer then the card visual for table 1 should show 9 while card visual for table 2 will show 6. If "Common" is selected at the slicer then the card visual for table 1 should show only 3 while the card visual for table 2 will only show 3 as well.

 

I'm trying to figure out how to achieve that with a measure that I will put into the card visual. This is what I have so far but it is just not working.

 

Count = 
VAR CurrentStatus = SELECTEDVALUE('Show Options'[Option])
VAR Checker = [Difference] \\this is the measure you provided in your solution
RETURN
SWITCH( 
    TRUE(),
    CurrentStatus = "Difference" , COUNTROWS(FILTER(Table, Checker <> 0 )),
    CurrentStatus = "Common" , COUNTROWS(FILTER(Table, Checker == 0)),
    CurrentStatus = "All", COUNTROWS(Table)
)

 

 

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.