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
Anonymous
Not applicable

Power Query - filter or split data import

Hi Forum

I havent managed to find a solution for this, i'm having the same 'structural issue' from multiple data exports from my systems. 

The data exported, includes a grouping as a header in the same column as the data. In my example the data exported is general ledger accounts. The column headings for each account is simple, date,description and amount. However, the account name appears in the same column as the data, so any filter on the data does not include the account name. A sample below:

DateDescriptionAmount
advertising  
2022/01/01aaa1
2022/01/01bbb2
   
suscriptions  
2022/01/01ccc5
2022/01/01ddd9
2022/01/01eee12
2022/01/01ffff11
   
maintenance  
2022/01/01ggg14
2022/01/01hhh13
2022/01/01iiii29

 

In order to do effective queries on the grouping, or label, i would ideally like the data to look this, adding the account name to each row.

AccountDateDescriptionAmount
advertising2022/01/01aaa1
advertising2022/01/01bbb2
suscriptions2022/01/01ccc5
suscriptions2022/01/01ddd9
suscriptions2022/01/01eee12
suscriptions2022/01/01ffff11
maintenance2022/01/01ggg14
maintenance2022/01/01hhh13
maintenance2022/01/01iiii29

 

Perhaps there is even an advanced data object i can use to place the values into. Any help would really be appreciated.

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Paste this code into a new blank query in PQ to see the steps I took:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZAxDsIwDEWvUmWuRBNg4CxRB8cxiQcMagLnx+mGTL/sP/jJ1pdjdJA/tHVuLMXNbtp7naMLSwinxWvpCADUvQUpJfWwg+lnv70bbvzq/JR2fBgR1a8W5JzVbxYQ0YgSLLmrBvJ/0jyApZOAIB2HKWW8wF8sqbUOcraEVeMDmnT9Ag==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Description = _t, Amount = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"Date", type text}, {"Description", type text}, {"Amount", Int64.Type}}),
    addAccount = Table.AddColumn(chgTypes, "Account", each if [Amount] = null then [Date] else null),
    fillDownAccount = Table.FillDown(addAccount,{"Account"}),
    filterNullAmount = Table.SelectRows(fillDownAccount, each ([Amount] <> null))
in
    filterNullAmount

 

SUMMARY:

 

1) Add column that picks up the account name where amount is null.

2) Fill down this new [Account] column.

3) Filter out null [Amount] values to only leave rows that have useful data

 

I get this output:

BA_Pete_0-1643014396024.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Paste this code into a new blank query in PQ to see the steps I took:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZAxDsIwDEWvUmWuRBNg4CxRB8cxiQcMagLnx+mGTL/sP/jJ1pdjdJA/tHVuLMXNbtp7naMLSwinxWvpCADUvQUpJfWwg+lnv70bbvzq/JR2fBgR1a8W5JzVbxYQ0YgSLLmrBvJ/0jyApZOAIB2HKWW8wF8sqbUOcraEVeMDmnT9Ag==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Description = _t, Amount = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"Date", type text}, {"Description", type text}, {"Amount", Int64.Type}}),
    addAccount = Table.AddColumn(chgTypes, "Account", each if [Amount] = null then [Date] else null),
    fillDownAccount = Table.FillDown(addAccount,{"Account"}),
    filterNullAmount = Table.SelectRows(fillDownAccount, each ([Amount] <> null))
in
    filterNullAmount

 

SUMMARY:

 

1) Add column that picks up the account name where amount is null.

2) Fill down this new [Account] column.

3) Filter out null [Amount] values to only leave rows that have useful data

 

I get this output:

BA_Pete_0-1643014396024.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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.