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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
leamsi-alvarado
Regular Visitor

Multiply Measure and column, before sum

Hello, i need to multiply a measure with a column, the problem is that it sums first, and then it does de mutliplication, this is the dax code im currently using: 

Variance per volume= 'PBI_ASN_Volume_Budget'[Variance Budget] * sumx('PBI_ASN_Fixed_Cost', 'PBI_ASN_Fixed_Cost'[FixedCost])

here is an example of the problem:
variance budget is for row  with ID 1 = 50 and for row with ID 2 = 100, the i have in fixed cost the fixed cost for the ID 1 = 0.52 and for the ID 2 = 0.75, what ia want is  (50 * 0.52) + (100*0.75) =  101, and what the code is doing right now is (50+100) * (0.52 + 0.75) = 190.5

Any ideas, thank you!  
1 ACCEPTED SOLUTION
JorgePBI
Advocate I
Advocate I

I would try it this way, 

 

Variance per volume = SUMX(
    'PBI_ASN_Fixed_Cost',
    'PBI_ASN_Fixed_Cost'[FixedCost] * 'PBI_ASN_Volume_Budget'[Variance Budget]
)

 

This could also help 

Variance per volume = SUMX(
    'PBI_ASN_Fixed_Cost',
    'PBI_ASN_Fixed_Cost'[FixedCost] * RELATED('PBI_ASN_Volume_Budget'[Variance Budget])
)

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@kjkjkjnk if that is the structure of the data which is very less likely, I will unpivot and then work on it, this is not the right shape of the data for the Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

kjkjkjnk
Helper I
Helper I

Assuming the data is laid out like this: 

IDFixedID2Fixed2
50.52100.75



I used these measures: 

Multiply ID 1 and Fixed 1 = SUMX('Table', 'Table'[Fixed] * 'Table'[ID])
Multiply ID 2 and Fixed 2 = SUMX('Table', 'Table'[Fixed2] * 'Table'[ID2])
Add Values = SUMX('Table', [Multiply ID 1 and Fixed 1] + [Multiply ID 2 and Fixed 2])



parry2k
Super User
Super User

@leamsi-alvarado the solution @JorgePBI  provided will work assuming there is a relationship between the tables, and also an important part is how these tables are related. Is it many to many or one to many relationship and which side is the one side?

 

Just having DAX will not do anything until there is a clear understanding of the relationship. My 2 cents.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

thank you!

JorgePBI
Advocate I
Advocate I

I would try it this way, 

 

Variance per volume = SUMX(
    'PBI_ASN_Fixed_Cost',
    'PBI_ASN_Fixed_Cost'[FixedCost] * 'PBI_ASN_Volume_Budget'[Variance Budget]
)

 

This could also help 

Variance per volume = SUMX(
    'PBI_ASN_Fixed_Cost',
    'PBI_ASN_Fixed_Cost'[FixedCost] * RELATED('PBI_ASN_Volume_Budget'[Variance Budget])
)

This works perfectly, i needed to make a better relationship but the dax code worked, thank you!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.