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
Anonymous
Not applicable

Function returning data type Any, not Text

I'm trying to improve M Language readability and reduce code by returning a text data type as opposed to returning a number and then converting it to text.

 

So far, I've tried using the Number.ToText method without luck. I've tried returning the number with double quotes around, i.e

if [Freq] = 12 then "3". Once you look at the column, however, the data type says "Any" as opposed to "Text". When you Close and Load the data to the workbook, the data type is "General" as opposed to Text.

 

Anyway I can return Text to avoid having to do so in a separate step?

 

image.png

1 ACCEPTED SOLUTION
Seth_C_Bauer
Community Champion
Community Champion

@Anonymous specifying "type text" at the end worked for me.

= Table.AddColumn(#"Changed Type", "Custom", each if [Type] = 3 then 2 else if [Type] = 12 then 3 else if [Type] = 24 then 2 else if [Type] = 26 then 8 else if [Type] = 52 then "1" else "", type text)


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

View solution in original post

1 REPLY 1
Seth_C_Bauer
Community Champion
Community Champion

@Anonymous specifying "type text" at the end worked for me.

= Table.AddColumn(#"Changed Type", "Custom", each if [Type] = 3 then 2 else if [Type] = 12 then 3 else if [Type] = 24 then 2 else if [Type] = 26 then 8 else if [Type] = 52 then "1" else "", type text)


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.