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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Gjakova
Post Patron
Post Patron

How to get missing values dynamically with DAX

Hi there, 

I have the following question:

 

I have two lists. Table A and Table B.

CountryCity
USANew York
USALos Angeles
GermanyBerlin

 

Table B looks like:

Country2

City2

USA

Los Angeles

SpainMadrid
AustraliaMelbourne

 

Table A and B can both change depending of my YEAR and MONTH filters, so I cannot use calculated columns or do this in Power Query.

I want to select a certain month and year, and depending on that, the values from table A and B change. So for 2022 November, it looks like above.

 

What I want to do is the following: I want to see which cities from Table A are missing in Table B. These results will be in my new table, which I will call Table C. Or I will conditionally format the cities that are missing.

So the results needs to look like, because those two cities are not in table B (now LA and Berlin are highlighted).

CountryCity
USANew York
USALos Angeles
GermanyBerlin

 

My current formula looks like this and I think it works, but I wanted to know if there is perhaps a better solution?

 

No Match =
IF(ISBLANK(LOOKUPVALUE(test[City2], test[City2], MIN(test[City]))), 1, 0)
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1670904816698.png

 

Jihwan_Kim_1-1670905854783.png

 

No match measure V1: =
SUMX (
    DISTINCT ( 'Table A'[City] ),
    CALCULATE (
        IF (
            COUNTROWS ( 'Table A' ) > 0,
            IF (
                COUNTROWS (
                    FILTER ( 'Table B', 'Table B'[City2] IN DISTINCT ( 'Table A'[City] ) )
                ) = 0,
                1,
                0
            )
        )
    )
)

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1670904816698.png

 

Jihwan_Kim_1-1670905854783.png

 

No match measure V1: =
SUMX (
    DISTINCT ( 'Table A'[City] ),
    CALCULATE (
        IF (
            COUNTROWS ( 'Table A' ) > 0,
            IF (
                COUNTROWS (
                    FILTER ( 'Table B', 'Table B'[City2] IN DISTINCT ( 'Table A'[City] ) )
                ) = 0,
                1,
                0
            )
        )
    )
)

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Thank you! This did work, I only had to create a table column but that was 1 minute work. Thanks again 😉

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.