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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nannimora
Helper I
Helper I

product between measure and column

Hi everyone,

my issue is that i have to create a measure that is a result of a product between another measure and a value of a column.

 

 

table 1: "Products"

CodDescriptionCost
XXXX1Descr XXXX10.3
XXXX2Descr XXXX21.79

 

Than i have my measure : Quantity

 

Quantity = CALCULATE(SUM(Sales[YY. Quantity]))


Now i have to show che Total Cost of each product where: Total Coast = Quantity x Cost

I tried with this measure:

 

 

Total Cost = 
CALCULATE(
    SUM('Table 1'[Cost])*[Quantity]
)

 

 

 

in each row of the table the result is correct. The issue is for the total:

the measure moltiply the sum of the quantity with the sum of the costs.

 

CodQuantityCostTotal Cost
XXXX11000.330
XXXX2501.7989.5
Total1502.09313.5

 

he does 150 * 2.09. 

but the right total is 30+89.5 = 119.5

 

Someone could help me to solve my problem?

 

thanks

 

GM

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @nannimora 

 

Use SUMX()

Total Cost = 
SUMX( Sales, Sales[YY. Quantity] * RELATED( 'Table 1'[Cost] ) )
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn



View solution in original post

2 REPLIES 2
v-lionel-msft
Community Support
Community Support

Hi @nannimora ,

 

You can refer to @Mariusz 's answer:

//the [Quantity] column is original data, which is not from DAX.
Measure 4 = 
SUMX(
    Sales,
    Sales[Quantity] * RELATED('Product'[Cost])
)

cc5.PNG

 

Best regards,
Lionel Chen

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

Mariusz
Community Champion
Community Champion

Hi @nannimora 

 

Use SUMX()

Total Cost = 
SUMX( Sales, Sales[YY. Quantity] * RELATED( 'Table 1'[Cost] ) )
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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