简体   繁体   中英

Calculate value on part of a Many-to-Many relationship in PowerPivot

I have a Many-to-Many relationship: dishes to their ingredients through link table.

在此处输入图片说明

I want to display a pivot table showing all ingredients of each dish with cost of each ingredient part and total cost of each dish. You should get the idea from the picture below except that actual values are somewhat spoiled. And here is why. cost of ingredient is a measure calculated by the following expression: =CALCULATE(SUM(dishes_ingredients[quantity])*SUM(ingredients[price]); dishes_ingredients)

Should I use calculated columns instead in dishes_ingredients and how do I properly reference ingredients table from there? Or should I take totally different approach?

在此处输入图片说明

I'm quite a newbie to Excel and that's sort of hobby, would be glad also if you recommend succinct, but comprehensive (overviewing concepts and gently moving to practical parts) reading.

Well, should have tried before posting. Calculated column is what I had to do. Was afraid to mess with column indices in VLOOKUP, but those are nicely referenced by their names in DAX.

=[quantity]*LOOKUPVALUE(ingredients[price]; ingredients[ingredient_id]; [ingredient_id])

在此处输入图片说明

And everything is now how it was mean to be.

在此处输入图片说明

Still open for suggestions on a good DAX/PowerPivot book.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM