Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello Evryone,
I have a requirement to find number of characters between 2 text string.
Am able to fetch the fix number of characters after the first text string(keyword) but how to extract total number of characters excluding space between 2 keywords here "Given" and "When"?
Note: These 2 keywords can be in one line or 2 different lines.
Ex 1.
Given When
Ex 2.
Given I am an Administrator
When I view Requirement Table
Then It should include IDD rules
Below is not the correct DAX. Just trying to fetch 50 characters out of it.
Solved! Go to Solution.
Hi @Anonymous ,
M query may be a better choice.
Try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("JYyxCoAwDAV/5dHZn3ASVxEcSoekBgzYiLXW31fqrXec927QKoYRlECGfk1qepVM5cgudN4tW9NV5cEk561ZkljBTLxLK/4DEYGZ0foYI9YPF8IL", 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}}),
#"Inserted Text Between Delimiter" = Table.AddColumn(#"Changed Type", "Text Between Delimiter", each (Text.BetweenDelimiters([Column1],"Given","When")), type text),
#"Replaced Value" = Table.ReplaceValue(#"Inserted Text Between Delimiter"," ","",Replacer.ReplaceText,{"Text Between Delimiter"}),
#"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "Custom", each if [Text Between Delimiter] = "" then null else Text.Length([Text Between Delimiter]))
in
#"Added Conditional Column"First use Text.BetweenDelimiters function to split a column by delimiters.
Then replace the space.
Finally, the Text.Length function is used to get the character length.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
M query may be a better choice.
Try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("JYyxCoAwDAV/5dHZn3ASVxEcSoekBgzYiLXW31fqrXec927QKoYRlECGfk1qepVM5cgudN4tW9NV5cEk561ZkljBTLxLK/4DEYGZ0foYI9YPF8IL", 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}}),
#"Inserted Text Between Delimiter" = Table.AddColumn(#"Changed Type", "Text Between Delimiter", each (Text.BetweenDelimiters([Column1],"Given","When")), type text),
#"Replaced Value" = Table.ReplaceValue(#"Inserted Text Between Delimiter"," ","",Replacer.ReplaceText,{"Text Between Delimiter"}),
#"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "Custom", each if [Text Between Delimiter] = "" then null else Text.Length([Text Between Delimiter]))
in
#"Added Conditional Column"First use Text.BetweenDelimiters function to split a column by delimiters.
Then replace the space.
Finally, the Text.Length function is used to get the character length.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous - Take your mid result, turn it into a table using Text to Table (word version), filter out blank rows and then use COUNTROWS across the table.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Text-to-Table/td-p/1312929
I just wanted the text between "given" and "when". Then I can find the length of the text string (excluding space) using LEN() and TRIM().
Note: These 2 keywords can be in one line or 2 different lines.
Ex 1.
Given When
Ex 2.
Given I am an Administrator
When I view Requirement Table
Then It should include IDD rules
But I am stuck to find the total string between "given" and "when". Sometimes it is giving correct result and sometimes exceeds beyond "when"
Below DAX is not giving correct result. Where am I going wrong?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 44 | |
| 43 | |
| 38 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 66 | |
| 31 | |
| 28 | |
| 24 |