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...
Anonymous
7 years agoNot applicable
Hey! First things first I'd advise you to use calculate(sum(.....)) instead of sumx(....) honestly it's easier to write and it performs better especially if you have larg(er) datasets. This should be more readeable:
sum(Calculate(1 * Price, Quantity_Type = "Total"), Calculate(Price * quantity, Quantity_Type <> "Total"))
or Calculate(1 * Price, Quantity_Type = "Total") + (Calculate(Price * quantity, Quantity_Type <> "Total")
Something like this should work I suppose.
- VulcanPromance7 years ago
Helper II
Cost_Licenses = CALCULATE(SUM([Count]*[Price])) does not work.Couldnt get it to work on your other two eitherCalculate(1 * Price, Quantity_Type = "Total") + (Calculate(Price * quantity, Quantity_Type <> "Total")Had to re-write them some, cause I assume I need the [] around the columns.. and I have no Quantity table. its in the license tableSo tried this.sum(Calculate(1 * [Price]; [Quantity_Type] = "Total"); Calculate([Price] * Licenses; [Quantity_Type] <> "Total"))It reports to many arguments in SUMTried thisCalculate(1 * [Price]; [Quantity_Type] = "Total") + Calculate([Price] * Licenses; [Quantity_Type] <> "Total")IT reports value of quantity type cannot be determined.