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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mtrevisiol
Helper V
Helper V

Difference between two tables

Hi everyone. I've got two tables:

the first is the Sales Table

mtrevisiol_2-1636445595028.png

which contains, for each product, the customer code, the date in which the sale took place, the quantity sold and the sale type (always invoice).

 

The second table is the Picking Table:

mtrevisiol_3-1636445623882.png

which represents the pickings from the warehouse, specifying items, customer, date, picking quantity and the inventory reason.

 

I would like to compare the two tables making the difference between them. Usually the picking from the warehouse occurs from 0 to 5 days before the movement of invoicement. So I could compare the tables by considering the same item, the same customer and a DocumentDate that is <= PostingDate + 6 days, to get the rows that are present in the first table, but not in the second. This is the ideal result:

mtrevisiol_4-1636446026995.png

 

Here is the pbix file: https://www.dropbox.com/s/lltioca2vpnn1t7/DifferenceTables.pbix?dl=0

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @mtrevisiol ,

 

First of all you need to create two table to addtional table (customer and Items) this will give you the dimension tables to relate your table then add the following measures:

 

Sum of Picking =
IF (
    ISBLANK ( SUM ( Tab1[SaleQty] ) ),
    BLANK (),
    CALCULATE (
        SUM ( Tab2[PickingQty] ),
        FILTER (
            ALL ( Tab2[PostingDate] ),
            Tab2[PostingDate]
                >= MAX ( Tab1[DocumentDate] ) - 6
        )
    )
)


Difference = if( (SUM(Tab1[SaleQty]) - [Sum of Picking])  = 0 , BLANK(),  (SUM(Tab1[SaleQty]) - [Sum of Picking]) )

 

Result below and attach.

 

MFelix_0-1636536226391.pngMFelix_1-1636536255542.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @mtrevisiol ,

 

First of all you need to create two table to addtional table (customer and Items) this will give you the dimension tables to relate your table then add the following measures:

 

Sum of Picking =
IF (
    ISBLANK ( SUM ( Tab1[SaleQty] ) ),
    BLANK (),
    CALCULATE (
        SUM ( Tab2[PickingQty] ),
        FILTER (
            ALL ( Tab2[PostingDate] ),
            Tab2[PostingDate]
                >= MAX ( Tab1[DocumentDate] ) - 6
        )
    )
)


Difference = if( (SUM(Tab1[SaleQty]) - [Sum of Picking])  = 0 , BLANK(),  (SUM(Tab1[SaleQty]) - [Sum of Picking]) )

 

Result below and attach.

 

MFelix_0-1636536226391.pngMFelix_1-1636536255542.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you @MFelix !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors