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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Comparing values of type text to integer

Hi,

 

Although I have heard of this error "You cannot compare values of type text to integer" a lot of times before, Im still not able to figure out what conversion I need to make with my below calculation. Please help

 

 

Calculated Column =
VAR id1 = [Feature ID]
RETURN
    IF (
        [Executed Flag] = 1,
        IF (
            CALCULATE (
                COUNTROWS ( 'Table' ),
                'Table'[Feature ID] = id1,
                'Table'[202/3 Flag] = 1
            ) = 2,
            IF (
                CALCULATE (
                    COUNTROWS ( 'Table' ),
                    'Table'[Feature ID] = id1,
                    'Table'[User Story Status] = "Complete or Closed"
                ) = 2,
                "Workshop Complete",
                "Workshop Executed but not Completed"
            ),
            "Workshop Executed but not Completed"
        ),
        "Not Executed"
    )

 

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Your [202/3 Flag]column was Text and it needed to be Whole Number type.

I've changed it and now your Calculated Column code works.

Download the PBIX

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

7 REPLIES 7
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Your [202/3 Flag]column was Text and it needed to be Whole Number type.

I've changed it and now your Calculated Column code works.

Download the PBIX

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thank you so much @PhilipTreacy Im slowly getting a jist of typecasting functionality in DAX now.

Can you please also help me the logic of the question on the other link. Tagged you there

@Anonymous 

Yes I find it frustrating that columsn that obviously contain numbers are still imported as text.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

@Anonymous 

It's not ideal to look at copied data like that, you can't tell if numbers are stored as text or numbers.  Much better to supply the PBIX file.

But, is your Executed Flag column Text data type? It should be Whole Number.

And there's no column called [202/3 Flag] in the data on that page you linked to. It should also be a numeric data type like Whole Number. Is it Text?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

@PhilipTreacy sorry for the confusion

Here is the link to the file

https://drive.google.com/file/d/1dY6mjEAKGdhi_9vI-jxSulwxGSQLVL9J/view?usp=sharing

 

 

If you can also help me resolve the other question(link given) i'll be obliged

PhilipTreacy
Super User
Super User

@Anonymous 

It's hard to say without seeing your data.

Somewhere in that code you're comparing a text value with a number.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Here is the data. This question is linked with this
https://community.powerbi.com/t5/Desktop/For-Each-and-Exists-clause-implementation-in-DAX/m-p/165433...

You can refer this as well

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.