Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
dancer10-10
New Member

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 5
Greg_Deckler
Community Champion
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.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you. Do you know the correct logic to get the formula that I want to get based on the description above? 

@dancer10-10 Try something like this:

Better Sales from New Customers - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

gained 2 = var current_customers= DISTINCT(Sales[customer ID]) var mindate = SELECTEDVALUE(Sales[YearONLY]) var selectedthreshold3= SELECTEDVALUE('Gain Loss Numbers'[numbers Gain/Loss]) var table_ = FILTER(ALL(Sales), IF(selectedthreshold3<[units],1) ) var previouscustomer= DISTINCT(SELECTCOLUMNS(table_, "customer ID", Sales[customer ID])) var newcustomer= EXCEPT(current_customers,previouscustomer) return SUMX(FILTER(Sales,Sales[customer ID] IN newcustomer),[units])

 

 

Is this correct? I am new to power bi. It says that there is not enough memory to complete operation. 

@dancer10-10 It's really tough to say. Can you post sample/example data?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors