Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hello, is there a simple way to insert a row every 3 rows?
My use-case is fairly straightforward, I need a repeating row #question_answer as in the sample:
#question_answer | bregjiewpjgrw |
#question | bregjiewpjgrw |
#answer | answer1 |
#question_answer | caherjtykukgkh |
#question | caherjtykukgkh |
#answer | answer2 |
#question_answer | abdscefefa |
#question | abdscefefa |
#answer | answer3 |
Script to insert here | Script to insert here |
#question | dwafegbbg |
#answer | answer4 |
Ideally, as shown, it would contain plain data (the string #question_answer )in the first column, and a reference to the cell below in the second.
Very grateful for any suggestions
Solved! Go to Solution.
Hi @Anonymous ,
We can use the following steps to meet your requirement.
if [Column 1] = "#question"
then {"New","Origin"}
else {"Origin"}
= Table.ReplaceValue(#"Expanded Temp",each [Column 1],each if [Temp] = "New" then "#question_answer" else [Column 1],Replacer.ReplaceText,{"Column 1"})
If you have any questions, please kindly ask here and we will try to resolve it.
All the queries are here:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bcs7DoAgEATQu6ytjZ/bGIpFllVIUPmEeHtJaEygm8zM2zYYnkQhnpeDEaQnNifl27DPIMayoguZfNlqmGr7Mzse5E18bbJsjy6aG4RShZ00aeyCpQEqoyaWkrv/FYT4AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column 1", type text}, {"Column 2", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Temp", each if [Column 1] = "#question"
then {"New","Origin"}
else {"Origin"}),
#"Expanded Temp" = Table.ExpandListColumn(#"Added Custom", "Temp"),
#"Replaced Value" = Table.ReplaceValue(#"Expanded Temp",each [Column 1],each if [Temp] = "New" then "#question_answer" else [Column 1],Replacer.ReplaceText,{"Column 1"}),
#"Removed Columns" = Table.RemoveColumns(#"Replaced Value",{"Temp"})
in
#"Removed Columns"
BTW, pbix as attached.
Best regards,
Hi @Anonymous ,
We can use the following steps to meet your requirement.
if [Column 1] = "#question"
then {"New","Origin"}
else {"Origin"}
= Table.ReplaceValue(#"Expanded Temp",each [Column 1],each if [Temp] = "New" then "#question_answer" else [Column 1],Replacer.ReplaceText,{"Column 1"})
If you have any questions, please kindly ask here and we will try to resolve it.
All the queries are here:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bcs7DoAgEATQu6ytjZ/bGIpFllVIUPmEeHtJaEygm8zM2zYYnkQhnpeDEaQnNifl27DPIMayoguZfNlqmGr7Mzse5E18bbJsjy6aG4RShZ00aeyCpQEqoyaWkrv/FYT4AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column 1", type text}, {"Column 2", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Temp", each if [Column 1] = "#question"
then {"New","Origin"}
else {"Origin"}),
#"Expanded Temp" = Table.ExpandListColumn(#"Added Custom", "Temp"),
#"Replaced Value" = Table.ReplaceValue(#"Expanded Temp",each [Column 1],each if [Temp] = "New" then "#question_answer" else [Column 1],Replacer.ReplaceText,{"Column 1"}),
#"Removed Columns" = Table.RemoveColumns(#"Replaced Value",{"Temp"})
in
#"Removed Columns"
BTW, pbix as attached.
Best regards,
This works perfectly. Thank you for the detailed writeup, it really helps me understand the method.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
88 | |
79 | |
63 | |
61 | |
59 |
User | Count |
---|---|
166 | |
114 | |
99 | |
73 | |
65 |