Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I have column with values, for example:
1.5 2.5
1-5 2-5
1/4 2/4
1. - 1. 2. - 3.
1 5 2 4
etc.
And I would like to return the second and fourth number/digit of the cell's value. Would it be possible to do that in the querry editor, with a formula or with another way?
Regards,
Edgars
Solved! Go to Solution.
Hi @Anonymous,
I made one sample for your reference. Please check the output as the picture as below.
M code in power query for your refernce.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzVTDSM1WK1QGydYFsXShb30TBSN8EwtZT0FUAEkYg2lgPIqYAVKsAlI8FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(List.RemoveNulls(List.Transform(Text.ToList([Column1]),each if Value.Is(Value.FromText(_), type number) then _ else null)))), #"Split Column by Position" = Table.SplitColumn(#"Added Custom", "Custom", Splitter.SplitTextByRepeatedLengths(1), {"Custom.1", "Custom.2", "Custom.3", "Custom.4"}), #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Position",{{"Custom.1", Int64.Type}, {"Custom.2", Int64.Type}, {"Custom.3", Int64.Type}, {"Custom.4", Int64.Type}}), #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Changed Type1", {{"Custom.2", type text}, {"Custom.4", type text}}, "en-US"),{"Custom.2", "Custom.4"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"), #"Changed Type2" = Table.TransformColumnTypes(#"Merged Columns",{{"Merged", type number}}) in #"Changed Type2"
For more details, please check the pbix as attached.
Regards,
Frank
Hi @Anonymous,
I made one sample for your reference. Please check the output as the picture as below.
M code in power query for your refernce.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzVTDSM1WK1QGydYFsXShb30TBSN8EwtZT0FUAEkYg2lgPIqYAVKsAlI8FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(List.RemoveNulls(List.Transform(Text.ToList([Column1]),each if Value.Is(Value.FromText(_), type number) then _ else null)))), #"Split Column by Position" = Table.SplitColumn(#"Added Custom", "Custom", Splitter.SplitTextByRepeatedLengths(1), {"Custom.1", "Custom.2", "Custom.3", "Custom.4"}), #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Position",{{"Custom.1", Int64.Type}, {"Custom.2", Int64.Type}, {"Custom.3", Int64.Type}, {"Custom.4", Int64.Type}}), #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Changed Type1", {{"Custom.2", type text}, {"Custom.4", type text}}, "en-US"),{"Custom.2", "Custom.4"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"), #"Changed Type2" = Table.TransformColumnTypes(#"Merged Columns",{{"Merged", type number}}) in #"Changed Type2"
For more details, please check the pbix as attached.
Regards,
Frank
Hi @Anonymous,
Does that make sense? If so, kindly mark my answer as a solution to close the case.
Regards,
Frank
I might have found a solution myself. I found a formula in one of the previous related posts:
Text.Combine(List.RemoveNulls(List.Transform(Text.ToList([Column1]),each if Value.Is(Value.FromText(_), type number) then _ else null)))
This one extracts only numbers without any other symbols. So I used this one and them used Text.Range formula to get the second and fourth value.
But maybe there's still a shorter way how it can be done?
@Anonymous
This might be another way. But its not shorter by any means
Text.Combine( List.RemoveItems(Text.ToList([Column1]), List.RemoveItems(Text.ToList([Column1]),{"0".."9"})))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |