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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
haleswd258
Regular Visitor

Dynamic Table Diff

I have a Sales Table that lists part numbers that have been purchased.  I also have a Required Stocking Table that contains the part numbers and quantities that we require our customers to stock.  I would like to use Power BI to select a particular customer ,along with other filters.  This would then populate a results table/grid visual with the part numbers and the quantities that the customer would need to purchase in order to be in compliant with our stocking policy. 

 

I have tried things like Table.RemoveMatchingRows(), but that is just a table, and cannot dynamically change based on selections.  At least to my understanding.  I have also tried making helper columns and filtering using contains() or calculate(counting rows(),filter(),etc... but I just can't get anything to work.  I'm sure it is just my lack of understanding.  Can anyone help me?

 

I'm sure it goes without saying, but I have greatly simplified the tables for this example.

 

Sales Table

Part_NoQtyCustomer
1004Cust A
2005Cust A
3005Cust A

 

Required Stocking Table

Part_NoQty
1005
2005
3005
4005

 

What the Results should look like based on what is shown here.

Part_NoQty
1001
4005

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @haleswd258 ,

 

Here's my solution.

1.Merge two tables.

vstephenmsft_0-1651741419919.png

vstephenmsft_2-1651741489779.png

 

2.Expand the column.

vstephenmsft_1-1651741469943.png

vstephenmsft_3-1651741571693.png

 

3.Replace the null in the Qty.1 column with 0

vstephenmsft_4-1651741662552.png

vstephenmsft_5-1651741671012.png

 

4.Add a custom column to get the stock quantities.

vstephenmsft_6-1651741849016.png

vstephenmsft_7-1651741855567.png

 

5.Remove the Qty column and the Qty.1 column. Rename the Custom column as the Qty column. You'll get the following.

vstephenmsft_8-1651741920446.png

Filter out the Qty=0.

vstephenmsft_9-1651741964921.png

vstephenmsft_10-1651741973476.png

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @haleswd258 ,

 

Here's my solution.

1.Merge two tables.

vstephenmsft_0-1651741419919.png

vstephenmsft_2-1651741489779.png

 

2.Expand the column.

vstephenmsft_1-1651741469943.png

vstephenmsft_3-1651741571693.png

 

3.Replace the null in the Qty.1 column with 0

vstephenmsft_4-1651741662552.png

vstephenmsft_5-1651741671012.png

 

4.Add a custom column to get the stock quantities.

vstephenmsft_6-1651741849016.png

vstephenmsft_7-1651741855567.png

 

5.Remove the Qty column and the Qty.1 column. Rename the Custom column as the Qty column. You'll get the following.

vstephenmsft_8-1651741920446.png

Filter out the Qty=0.

vstephenmsft_9-1651741964921.png

vstephenmsft_10-1651741973476.png

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Vijay_A_Verma
Super User
Super User

Solution file uploaded to - https://1drv.ms/x/s!Akd5y6ruJhvhuUyWSf8XMDiJRclu?e=RWqsLW 

let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Part_No", Int64.Type}, {"Qty", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Sales[Qty]{List.PositionOf(Sales[Part_No],[Part_No])}),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each [Qty]-[Custom]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Qty", "Custom"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom.1", "Qty"}}),
    #"Filtered Rows" = Table.SelectRows(#"Renamed Columns", each ([Qty] <> 0))
in
    #"Filtered Rows"

 

Thank you for this.  So, this is for Excel.  I have been able to pretty much adapt it to Power BI to be able to create a table, but it just creates a table.  If I am in Power BI and I want to filter by customer, or any other field, the table doesn't refresh.  Is there some form of solution using a visual that would make this more functional?

Excel is used for demonstration as that is the easiest portable way to make you read the query. In place of Excel which is Source line, you can put your own source say any database etc. Is it possible for you to post your pbix file?

Sorry, I can't post the pbix.  It has too much proprietary info.  And as I said, I can get it to work in PowerBI the way it is.  I just need something that is more dynamic and can work from a dashboard

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.

Top Solution Authors
Top Kudoed Authors