cancel
Showing results for 
Search instead for 
Did you mean: 
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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.