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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How do I convert a columns datatype in DAX?

Hoping this will be easy to answer. 

 

I have a table which contains student results. Because of the different types of result that exist (9 to 1, and A to E), the data type has to be a string. 

 

I have filtered my table to only show those grades that are 9 to 1, but as the data has to be live, I cannot change the column data type. 

 

I need to create a measure that gets the sum of all of the grades for a given student, so need to convert the string values to integer values using DAX. Can this be done?

1 ACCEPTED SOLUTION
AmiraBedh
Super User
Super User

Can you try the following ? :

Total Grades =
SUMX(
FILTER(YourTableName, ISNUMBER(VALUE(YourGradeColumn))),
IF(
ISERROR(VALUE(YourGradeColumn)),
0,
VALUE(YourGradeColumn)
)
)

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @Anonymous,

You can add a filter in your table to exclude the A to E text string, then you can use value function to convert these to numeric before aggregating these values.

formula =
SUMX (
    ADDCOLUMNS (
        FILTER (
            ALLSELECTED ( Table1 ),
            NOT ( [Results] IN { "A", "B", "C", "D", "E" } )
        ),
        "Score", VALUE ( Table1[Results] )
    ),
    [Score]
)

Regards,
Xiaoxin Sheng

AmiraBedh
Super User
Super User

Can you try the following ? :

Total Grades =
SUMX(
FILTER(YourTableName, ISNUMBER(VALUE(YourGradeColumn))),
IF(
ISERROR(VALUE(YourGradeColumn)),
0,
VALUE(YourGradeColumn)
)
)

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
Kishore_KVN
Super User
Super User

Hello @Anonymous 

Use FORMAT DAX function to change the datatype of that particular column in your calculations. 

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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