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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
smpa01
Super User
Super User

Testing if integer in PBI (M not DAX)

Hello experts,

 

Is it possible for M to test whether my number values are integers?

 

Column1
0.2212
0.45554321
0.6
0.84321896
1
1.2
1.000004
1.76219026
1.8212154
2

Raw Data

Column1Is Integer?
0.2212F
0.45554321F
0.6F
0.84321896F
1T
1.2F
1.000004F
1.76219026F
1.8212154F
2T

 

 Desired Output

Thank you in advance.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
2 ACCEPTED SOLUTIONS

@smpa01 

 

How about this as a custom column

 

=if [Column1]=Int64.From([Column1]) then "T" else "F"

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, use this M code

=if Number.Mod([Column1],1)=0 then "T" else "F"

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, use this M code

=if Number.Mod([Column1],1)=0 then "T" else "F"

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
smpa01
Super User
Super User

I am not sure if M has a syntax that can check for "is integer". If someone knows about it and please points me to the right direction that would be great.

 

In the meantime, I thought of something like this.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("LYzBDcAwCAN3ybtC2IWUzBJl/zUaBP7Yhy32HiokOM6T0dzdXqJxtkfeYhVWCWG7pqzhm8RS9lLivoZXeffnBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type number}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Column1", "Column1 - Copy"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Duplicated Column",{{"Column1 - Copy", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type1", "Column1 - Copy", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Column1 - Copy.1", "Column1 - Copy.2"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1 - Copy.1", Int64.Type}, {"Column1 - Copy.2", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type2", "Custom", each if [#"Column1 - Copy.2"]=null then "T" else "F"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1 - Copy.1", "Column1 - Copy.2"})
in
    #"Removed Columns"

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01 

 

How about this as a custom column

 

=if [Column1]=Int64.From([Column1]) then "T" else "F"

@Zubair_Muhammad  great thanks. I can loose two steps with your solution. Do you know if there is any built-in M syntax that tests for an integer?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.