Forum Discussion
VulcanPromance
Helper II
7 years agoCreating a measure for Cost
I have this visualization The cost license measure calculates price*count. However, I need an if statement to be able to calculate cost differently if the quantity type is pr license or tot...
sdjensen
Solution Sage
7 years agoHi 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