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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
stribor45
Post Prodigy
Post Prodigy

Type error when using FORMAT function

I have this code in my measure which is giving  me type error

 

MyMeasure = 
VAR C = [Measure B]
VAR P =  [Measure B]
VAR DIFF = P - C
VAR PERC = ROUND(DIVIDE(DIFF, C, BLANK()) * 100, 2)

RETURN FORMAT(PERC, "0.0%")

and I am receiving this error "comparison operation do not support comparing values of type Text with values of type Number. Consider using the VALUE of FORMAt function to convert one of the value

1 ACCEPTED SOLUTION
stribor45
Post Prodigy
Post Prodigy

I change it to this

 

 

VAR PERC = DIVIDE(DIFF, C, BLANK())

RETURN PERC

 

and change from General to Percentage

stribor45_0-1705003966741.png

works fine now

 

View solution in original post

8 REPLIES 8
stribor45
Post Prodigy
Post Prodigy

I change it to this

 

 

VAR PERC = DIVIDE(DIFF, C, BLANK())

RETURN PERC

 

and change from General to Percentage

stribor45_0-1705003966741.png

works fine now

 

stribor45
Post Prodigy
Post Prodigy

as soon as I remove the format function works fine. These values are going into a table that shows values for the current date selection and previous year selection

stribor45
Post Prodigy
Post Prodigy

how can i output the type of the variable TYPE(variable) doesn't work for me

stribor45
Post Prodigy
Post Prodigy

sorry thats my bad. Should be like this

VAR C = [Measure A]

 

Hi @stribor45 

If you check, I am using the same measure (may be data value is not correct) but it will not showing me the error.
Please check all field's datatype including what column your are using for Measure A and Measure B

PijushRoy_0-1705001175481.png

 

If require, pelase share sample data or pbix file google drive link

If your requirement is solved, please make sure to MARK AS SOLUTION and help other users find the solution quickly. Please hit the LIKE button if this comment helps you.

Thanks
Pijush
www.MyAccountingTricks.com 
https://www.youtube.com/MyAccountingTricks

 



 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





stribor45
Post Prodigy
Post Prodigy

I already did that. When I output these values to my table I see numbers. Each of the variables displays similar numbers

 

stribor45_0-1705000272798.png

 

Hi @stribor45 

Your DIFF should be always 0, right? Because you are suing same measure for C and P

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





PijushRoy
Super User
Super User

Hi @stribor45 

Please check what is the datatype of [Measure B] text or number

To troubleshoot the issue
In the return statement, Put one by one variable C, P, DIFF, PERC and check what is returning. You can easily find the step which have error.

For Percent formatting, please use below fucntion 
https://learn.microsoft.com/en-us/dax/format-function-dax 

PijushRoy_0-1704998965666.png


If your requirement is solved, please make sure to MARK AS SOLUTION and help other users find the solution quickly. Please hit the LIKE button if this comment helps you.

Thanks
Pijush
www.MyAccountingTricks.com 
https://www.youtube.com/MyAccountingTricks

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.