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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BrittH
Regular Visitor

Change data type of measure with numeric AND text values

Hello!

I have a survey question which is answered on a 1-10 scale, which makes it numeric. However, there is also the answer option 'did not attend', which makes it non-numeric (text). The data type in PowerBI is now text, but I want to make it fixed number so that I can show the average answer (number) in my dashboard. How can I do that while maintaining the 'did not attend' answers? Because if I simply change it to fixed number, I get errors where previously 'did not attend' was. 

Thanks! 🙂

7 REPLIES 7
Alex87
Solution Sage
Solution Sage

maybe you can replace BLANK() with 0 in the formula provided and add a filter on the filter pane of the reporting page to exclude all "did not attend" rows. (if not it will false the amount of your average). Hope it helps 




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

Proud to be a Super User!




Thank you @Alex87 . This still doesn't work. I get the same message. Can it be that I should not use "" around did not attend in the formula? 

Hello @BrittH ,

 

I built a dummy dataset as follows:

Alex87_1-1716974350290.png

 

The answer column is typed: Text

I created a new calculated column

SurveyNumeric = 
SWITCH(
    TRUE(),
    [Answer] = "did not attend", BLANK(),
    VALUE([Answer])
)

now my table looks like this:

Alex87_2-1716974441764.png

I created a DAX measure: 

AverageSurveyResponse = AVERAGE([SurveyNumeric])

I then created Table visual using Survey Question & the created measure

 

Alex87_3-1716974514844.png

So, it is working. Did you do something different then the described steps mentioned above?

 

Best regards




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

Proud to be a Super User!




Hi @Alex87 , 

 

Thank you for your effort. The difference between your data and my data is that I only have one column. Let's name it 'session 1'. Then all the cells in that column are either a number (the rating respondents give that session) or 'did not attend'. 

 

I have solved this issue with a workaround. I created another column in Excel and called it 'session 1 without did not attend'. In that column, I emptied all the did not attend cells. With that column, I can show the average rating in PowerBI. 

 

Sorry Brit, I do not understand. I created in the dataset 1 column only as well. That column contains both numeric and text values (column "Answer"). I then create in DAX a calculated column and I finalize with a DAX measure. No workaround is needed.

Can you please mock up for me a sample example please?




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

Proud to be a Super User!




Alex87
Solution Sage
Solution Sage

1) Ensure Data is Text in Power Query

2) Create a Calculated Column in DAX :

SurveyNumeric = 
SWITCH(
    TRUE(),
    [SurveyResponse] = "did not attend", BLANK(),
    VALUE([SurveyResponse])
)

3) Create Measures for Average Calculation in a visualization

AverageSurveyResponse = AVERAGE([SurveyNumeric])



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

Proud to be a Super User!




Thank you @Alex87 ! When I create the calculated column I get this error message: cannot convert value "" of type Text to type Number. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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