Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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:
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:
Any help/guidance would be much appreciated!
Thanks,
Jason
Solved! Go to Solution.
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.
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]
)
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.
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]
)
@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!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 68 | |
| 33 | |
| 32 | |
| 31 |