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
07gt
New Member

Transaction Table to Current Inventory

Hello, 

 

I'm very new to PowerBI and I'm looking for help turning my transaction table into a current inventory table. See transaction data in picture here:

07gt_0-1688211046150.png

I have two bins (Bin1 and Bin2) which contain product and I can't figure out how to write a table formula to summarize the quantity in each. Essentially the formula should be Sum(Quantity To BinX) - Sum(Quantity From BinX), but I don't know how to write it in DAX. I need an output table that looks like this:

 

07gt_1-1688211690571.png

Any help/guidance would be much appreciated!

 

Thanks,

 

Jason

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1688240503258.png

 

 

New Table = 
VAR _ToTable =
    GROUPBY (
        FILTER ( Data, Data[To] <> "Sales" ),
        Data[To],
        "@Qty", SUMX ( CURRENTGROUP (), Data[Quantity] )
    )
VAR _FromTable =
    GROUPBY (
        FILTER ( Data, Data[To] = "Sales" ),
        Data[From],
        "@Qty", SUMX ( CURRENTGROUP (), Data[Quantity] )
    )
VAR _ResultTable =
    ADDCOLUMNS (
        _ToTable,
        "@fromQty", SUMX ( FILTER ( _FromTable, Data[From] = Data[To] ), [@Qty] )
    )
RETURN
    SELECTCOLUMNS (
        SUMMARIZE (
            ADDCOLUMNS ( _ResultTable, "@ResultQty", [@Qty] - [@fromQty] ),
            Data[To],
            [@ResultQty]
        ),
        "Bin", Data[To],
        "Quantity", [@ResultQty]
    )

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.


Click here to visit my LinkedIn page

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1688240503258.png

 

 

New Table = 
VAR _ToTable =
    GROUPBY (
        FILTER ( Data, Data[To] <> "Sales" ),
        Data[To],
        "@Qty", SUMX ( CURRENTGROUP (), Data[Quantity] )
    )
VAR _FromTable =
    GROUPBY (
        FILTER ( Data, Data[To] = "Sales" ),
        Data[From],
        "@Qty", SUMX ( CURRENTGROUP (), Data[Quantity] )
    )
VAR _ResultTable =
    ADDCOLUMNS (
        _ToTable,
        "@fromQty", SUMX ( FILTER ( _FromTable, Data[From] = Data[To] ), [@Qty] )
    )
RETURN
    SELECTCOLUMNS (
        SUMMARIZE (
            ADDCOLUMNS ( _ResultTable, "@ResultQty", [@Qty] - [@fromQty] ),
            Data[To],
            [@ResultQty]
        ),
        "Bin", Data[To],
        "Quantity", [@ResultQty]
    )

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.


Click here to visit my LinkedIn page

@Jihwan_Kim  this worked perfectly, thanks so much! The actual inventory table has a lot more detail, so ill adapt what you've written here to filter the way I need to. Appreciate it!

Thanks @Jihwan_Kim , I will give it a try and let you know how it goes!

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 Fabric 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.