Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Here are the images of two tables. We need to calculate the total cost for each item code. the quantity is coming from first table and the cost on a given date is coming from another table. there is an exmaple given for a better understanding of the calcuation. like, during October, the quantity against item code 521732 is 50 and its weighted running average cost in cost table is 11.50, so the TotalCost is 575= 50*11.50. I need a dax formula for this calculation. Actually doing the calculation across table has some issue due to many to many relations through Item code column. Please suggest a workable solutions for a large data set.
Solved! Go to Solution.
Try this MEASURE in QUANTITYTABLE..
WR to use = CALCULATE ( FIRSTNONBLANK ( CostTable[WeightedAverage], 1 ), FILTER ( CostTable, CostTable[Item Code] = SELECTEDVALUE ( QuantityTable[Item Code] ) && CostTable[Month] = MONTH ( SELECTEDVALUE ( QuantityTable[Use_Date] ) ) && CostTable[Year] = YEAR ( SELECTEDVALUE ( QuantityTable[Use_Date] ) ) ) )
then
TotalCost_WR = Sum(QuantityTable[Quantity])*[WR to use]
If you want a calculated column....you just have to remove selectedvalue function.....i,e
WR_to_use = CALCULATE ( FIRSTNONBLANK ( CostTable[WeightedAverage], 1 ), FILTER ( CostTable, CostTable[Item Code] = QuantityTable[Item Code] && CostTable[Month] = MONTH ( QuantityTable[Use_Date] ) && CostTable[Year] = YEAR ( QuantityTable[Use_Date] ) ) )
Try this MEASURE in QUANTITYTABLE..
WR to use = CALCULATE ( FIRSTNONBLANK ( CostTable[WeightedAverage], 1 ), FILTER ( CostTable, CostTable[Item Code] = SELECTEDVALUE ( QuantityTable[Item Code] ) && CostTable[Month] = MONTH ( SELECTEDVALUE ( QuantityTable[Use_Date] ) ) && CostTable[Year] = YEAR ( SELECTEDVALUE ( QuantityTable[Use_Date] ) ) ) )
then
TotalCost_WR = Sum(QuantityTable[Quantity])*[WR to use]
If you want a calculated column....you just have to remove selectedvalue function.....i,e
WR_to_use = CALCULATE ( FIRSTNONBLANK ( CostTable[WeightedAverage], 1 ), FILTER ( CostTable, CostTable[Item Code] = QuantityTable[Item Code] && CostTable[Month] = MONTH ( QuantityTable[Use_Date] ) && CostTable[Year] = YEAR ( QuantityTable[Use_Date] ) ) )
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
73 | |
58 | |
36 | |
32 |
User | Count |
---|---|
90 | |
62 | |
61 | |
49 | |
45 |