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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
MightyRabbit
Frequent Visitor

Query to subtract column from different Table

Dear all, 

Could you please kindly help with the querry to subtract 1 column from another table.
I have "table 1" with Column "No" Like the one below:

No
A1
A2
A1
A2
A3
A4
A5

 

I have "Table 2" with Column "No_deleted" as following:

No_deleted
A1
A4


How can I subtract Column "No" from table 1 to column "No_deleted" in table 2, and putting the result like following:

NoResult
A10
A2A2
A10
A2A2
A3A3
A40
A5A5


Thank you very much for your help.
Best regards,

1 ACCEPTED SOLUTION
rubayatyasmin
Community Champion
Community Champion

Hi, @MightyRabbit 

 

try to use calculate and all with IF and NOT DAX func

 

the code will be something like

 

Result = 
    CALCULATE(
        IF(
            NOT(CONTAINS(table2, table2[No_deleted], table1[No])),
            table1[No],
            "0"
        ),
        ALL(table2)
    )

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


View solution in original post

2 REPLIES 2
MightyRabbit
Frequent Visitor

Hi @rubayatyasmin ;

That works perfectly. Thanks 🙂

rubayatyasmin
Community Champion
Community Champion

Hi, @MightyRabbit 

 

try to use calculate and all with IF and NOT DAX func

 

the code will be something like

 

Result = 
    CALCULATE(
        IF(
            NOT(CONTAINS(table2, table2[No_deleted], table1[No])),
            table1[No],
            "0"
        ),
        ALL(table2)
    )

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors