Forum Discussion
Help with power bi dax calculation.
I am getting an error saying Dax comparison operations do not support comparing values of text with values of type number. How to fix?
I have this formula. I am trying to see if a customer is a gained customer compared to the year prior and the rest of the years before the current year. I want to write a formula that says if in the current year the customer did (selectedthreshold value) or more and in the prior year they did less than that value then they are a gained customer.
I have this right now.
gained customer =
var selectedthreshold = selectedvalue('Table'[number])
var currentyear= selectedvalue('time'[year])
var prioryear= (currentyear)-1
return
calculate(countrows, filter, values(sales[customerID]),
calculate(units, 'time'[year]=currentyear)>= selectedthreshold && calculate(units, 'time'[year]= prioryear)<selectedthreshold )))
please help. I am not sure if I have the right logic as well.
5 Replies
- Greg_Deckler
Community Champion
dancer10-10 Check the data types of your columns, number and year and make sure they are all set to Whole number or Decimal. Or, you can always do +0 to make sure any numeric text gets converted to a number.
Also, I have no idea what this line is:
calculate(countrows, filter, values(sales[customerID]),
calculate(units, 'time'[year]=currentyear)>= selectedthreshold && calculate(units, 'time'[year]= prioryear)<selectedthreshold )))
It doesn't look right at all.
- dancer10-10New Member
Thank you. Do you know the correct logic to get the formula that I want to get based on the description above?
- Greg_Deckler
Community Champion
dancer10-10 Try something like this:
Better Sales from New Customers - Microsoft Fabric Community