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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jmdesigns115
Microsoft Employee
Microsoft Employee

Help with dax code to filter results based on IF

Hello, I have two tables of data and i'm trying to pull them both into a single table and also filter the results based on IF.

 

Here is sample data and what i'm trying to accomplish.

 

I have a relationship between tbl1 and tbl2 on SKU. What i want to do is say IF(TBL1[skutype]=TEST-A, "Test-A", "test-B") what it's doing is duplicating the rows and showing me both TEST-A and TEST-B but i want it to only show me Test-A in the results. Basically if TEST-A and TEST-B both exist for SKU A to show Test-A only.

Input TBL1  Input TBL2  
SKUSKU TYPE SKUQTYDATE
ATEST-A A101/1/2020
ATEST-A A101/1/2020
ATEST-B A102/1/2020
BTEST-A B101/4/2020
CTEST-B C101/5/2020
      

 

 

 

Desired

output visual table

IF SKU IS SAME BUT TYPE IS DIFFERENT OVERRIDE AND SHOW TEST-A AND SUM QTY
SKUQTYDateSKU TYPE
A201/1/2020TEST-A
A102/1/2020TEST-A
B101/4/2020TEST-A
C101/5/2020TEST-B
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @jmdesigns115 
Please refer to attached sample file with the solution

1.png

SKU TYPE = 
VAR CurrentSKUTypes = 
    CALCULATETABLE ( 
        VALUES ( TBL1[SKU TYPE] ), 
        REMOVEFILTERS ( ), 
        VALUES ( TBL1[SKU] ) 
    )
RETURN
    IF ( 
        NOT ISEMPTY ( TBL1 ) && HASONEVALUE ( TBL1[SKU] ),
        IF ( 
            "TEST-A" IN CurrentSKUTypes,
            "TEST-A",
            "TEST-B"
        )
    )

View solution in original post

7 REPLIES 7
andhiii079845
Solution Sage
Solution Sage

Hi, 
to be honest i do not really understand your problem. You have a relationship betweeen both table with SKU. But it seems to be a m:n relationship. Because SKU "A" has "TEST-A" and "TEST-B", also duplicated values for SKU "A" and "Test-A" in table 1. Also your desired result is for my personal not clear. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




tamerj1
Super User
Super User

Hi @jmdesigns115 
Please refer to attached sample file with the solution

1.png

SKU TYPE = 
VAR CurrentSKUTypes = 
    CALCULATETABLE ( 
        VALUES ( TBL1[SKU TYPE] ), 
        REMOVEFILTERS ( ), 
        VALUES ( TBL1[SKU] ) 
    )
RETURN
    IF ( 
        NOT ISEMPTY ( TBL1 ) && HASONEVALUE ( TBL1[SKU] ),
        IF ( 
            "TEST-A" IN CurrentSKUTypes,
            "TEST-A",
            "TEST-B"
        )
    )

One side questions: Can only superuser upload directly files in this forum? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@andhiii079845 
Superusers, community support and perhaps Microsof employees

This feels like it's on the right track but my SKU Type comes up empty. Having troule figuring out why it's returning nothing.

@jmdesigns115 
Would you please update the same sample file with data that better simulates the actual case?

Thank you so much! Your solution worked. I accidentally chose new column instead of new measure when i used your solution. After making it a measure it worked.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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