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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
06jakegillespie
Regular Visitor

Calculating (matrix index * a value), then matching to a table based on the description

I have 3 tables to work with that share a relation to eachother... I will use a dummy data set for data privacy purposes. 


Orders                                                                                                           

Ordersdrawn.png 

Ingredient Matrix     

  ingredientMatrix.png

 Ingredient List

    ingredientListdrawn.png

 

 

Quantity in Ingredient list will be the (Σ Orders[Order]) * (Index('Ingredient Matrix'[Column1],[Row1]))

 

For example, say we had a slicer for Order type

06jakegillespie_1-1661980376847.png

our Ingredient List would show the quantities of the formula...

Σ(Σ Orders[Order]) * (Index('Ingredient Matrix'[Column1],[Row1]))

       2 Cake          *          1 Egg = 2 Egg

       2 Cake          *          2 Flour = 4 Flour

       2 Cake          *          3 Vanilla = 6 Vanilla

       2 Cake          *          1 Chocolate = 2 Chocolate

 

So you could essentially be able to slice by any of the attributes and get a running total of what you need to go and buy.

 

I was able to do this with excel pretty easily given that it has hlookup, but the lack of ability to transpose search values makes it quite difficult to do.

Similar forum posts revolve around using unpivot query but the formulas in themselves are confusing me... 

 

I currently use the formula zEgg = SUMX(Orders, RELATED(IngredientMatrix[Egg])) as a measure and it works, but I have to run this calculation for each ingredient. I would have zEgg, zFlour, zVanilla, zChocolate... It gets tedious when I am working with 30+ parts in my real data set. 

 

Would appreciate any insight, as I am new to DAX.  It seems like it has the same capabilites of Excel, it just requires you to jump  through a lot more hoops. 

 

 

 

1 REPLY 1
davehus
Memorable Member
Memorable Member

Hi @06jakegillespie , If you unpivot the ingredient matrix in powerquery, this will normalize your data and make calculations easier.

 

https://support.microsoft.com/en-us/office/unpivot-columns-power-query-0f7bad4b-9ea1-49c1-9d95-f5882...

 

Hope this helps,

 

Did I help you today? Please accept my solution and hit the Kudos button.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.