Forum Discussion
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:
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!
- Anonymous2 years ago
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]) )
6 Replies
- parry2kSuper User
leamsi-alvarado the solution Anonymous 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.
- leamsi-alvaradoRegular Visitor
thank you!
- AnonymousNot applicable
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]) )- leamsi-alvaradoRegular Visitor
This works perfectly, i needed to make a better relationship but the dax code worked, thank you!
- AnonymousNot applicable
Assuming the data is laid out like this:
ID Fixed ID2 Fixed2 50 .52 100 .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]) - parry2kSuper User
Anonymous 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.