Forum Discussion
Creating a measure for Cost
Hi VulcanPromance,
It seem like you have all 3 columns availeble in the same table, so why not just add your cost calculation as a calculated column instead of a measure? I am aware of the extra cost involved with calculated columns, but it's an easy fix and you would need a lot of data for this to have a mentionable performance penalty in this case.
Cost_Licenses =
IF(
Licenses[Quantity_Type] = "Total";
Licenses[Price];
Licenses[Price] * Licenses[Count]
)
Should also work as a measure like this:
Cost_Licenses_Meas = VAR CostTotal = CALCULATE( SUM(Licenses[Price] ); Licenses[Quantity_Type] = "Total" ) VAR CostPrLic = CALCULATE( SUMX( Licenses; Licenses[Price] * Licenses[Count] ); Licenses[Quantity_Type] <> "Total" ) RETURN CostTotal + CostPrLic
- VulcanPromance7 years ago
Helper II
Hi sdjensen
All versions yield the same result.. maybe it wasnt too clear..
For quantity type Total the Cost_Licenses should be 482. Cause its an enterprise cost. I.e. Portal access costs 482Euro a month regardless of count.
But as you can see your Measure and your Column yields the same result as my Cost Licenses which does not contain an IF.
- VulcanPromance7 years ago
Helper II
Hi.
Using this formula works (I just swapped SUM to MAX under var CostTOtal). I have no idea why.
Cost Measure =VAR CostTotal = CALCULATE(MAX(Licenses[Price]);Licenses[Quantity_Type]="Total")VAR CostPrLic = CALCULATE(SUMX(Licenses; Licenses[Price]*Licenses[Count]);Licenses[Quantity_Type]<>"Total")RETURNCostTotal + CostPrLic