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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
satyendra
Regular Visitor

Calculating a value by multiplying numbers in two columns of two different tables

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. 

Consumption Table.PNGCost Table.PNG

 

 

 

2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

@satyendra

 

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]

 

View solution in original post

@satyendra

 

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] )
    )
)

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@satyendra

 

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]

 

@satyendra

 

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] )
    )
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors