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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
cgkas
Helper V
Helper V

How to insert text in specific blank lines?

Hi,

 

May someone help me in how to add the word "SUB_BLOCK" inside the "BLOCKS_TYPE_1" that have empty lines between text, and remove rest of empty lines.

 

The Column1 looks like this

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZLLDsIgEEV/ZcLaha3vhYsWatOC0kgrVtL0//9CxFhfGWYWkwAnd3Lv4BzLleZybPumGBM2zBwLDZDKYA9JlMg9sYoS3BMLepTw2DxKFBNBCi1JobirciLQ9hckppVN/jHikWFKZrglXa9J17socfjeFG44/XnCBF/mNiTFyZX4OgIZpa8zvL/kR+8uHDKpQFZGV1C2xppwf+1vT+CkVdNYkKIW4SythdoI4B5nw3AH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [COLUMN1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"COLUMN1", type text}})
in
    #"Changed Type"
COLUMN1
BLOCK_TYPE_1

                        A = 1
                        B = 5
                        C = 3

                        D = 0
                        E = 0

                        D = 4
                        E = 1
                        G = 1





BLOCK_TYPE_1
                        A = 3
                        B = 2
                        C = 8
                        D = 6
                        E = 9
                        F = 3




BLOCK_TYPE_2


                            B = 7
                            C = 1
                           M  = 3
                           R  = 5
 
 
UVC AKL KISOI GTSWS
XYZ 
NOLPPW KDJD
KWW JSD COI 

 

Below is the input column and output column I'm looking for, to the right, showing in yellow the "main block" lines and the new "sub blocks" lines in blue and rest of empty lines removed.

 

image.png

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @cgkas,

You can refer to the following blog to know how to use isfiltered function to check current hierarchy level, then you can use if statement with these to accuracy replace specific cell values:

Clever Hierarchy Handling in DAX - SQLBI

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft thanks for share that info, but it seems is for DAX not for M language. Thanks anyway.

amitchandak
Super User
Super User

@cgkas , check if extended dimension can help, the way I used it P&L

Power BI How to get the P&L formatting right: https://youtu.be/C9K8uVfthUU

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks for the link. I think the video you shared is for another kind of problem, since uses DAX formulas. I'd like to use only M code.

Helpful resources

Announcements
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.