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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
cmncp
Helper III
Helper III

Power Query Merge for range of account numbers

I am doing some Financial / GL Reporting, and need to expand a From/To range of GL Accounts into a list of account numbers.

 

The following image shows the requirement:

- I have a Financial Statement table which contains From / To account groupings

- I also have a GL Account table which lists all GL accounts

- I need to merge these 2 to generate the "New Merged Table" on the right

 

cmncp_0-1599011330448.png

For example, if you look at the Assets type, it contains all accounts between 00010000 and 00019999.  So when this gets merged with the GL account table, it needs to populate with the 3 GL accounts that exist within this range.

 

I assume I will need to write some custom "M" code to do this, but I can't figure out the code.  Any help is greatly appreciated.

 

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@cmncp , in Dax you have crossjoin .

Try like

filter(crossjoin([financial statement],[Account]), [Account] <=[to Account] && [Account]>=[from Account])

 

Cross join do no take same column name from two tables, so use selectcolumns to rename if needed

https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/

 

M - https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

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
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Financial Statement Table

Statement NameTypeFrom AccountTo Account
All AccountsAssets0001000000019999
All AccountsLiabilities0002000000029999
All AccountsExpenses0003000000039999
All AccountsIncome0004000000049999
P&LExpenses0003000000039999
P&LIncome0004000000049999

 

Accounts Table

AccountDescription
00010000Asset A
00010001Asset B
00010003Asset C
00020000Liability A
00020001Liability B
00020003Liability C
00020000Expense A
00020001Expense B
00020003Expense C
00020000IncomeA
00020001IncomeB
00020003IncomeC

 

New Merged Table

Statement NameTypeAccountDescription
All AccountsAssets00010000Asset A
All AccountsAssets00010001Asset B
All AccountsAssets00010003Asset C
All AccountsLiabilities00020000Liability A
All AccountsLiabilities00020001Liability B
All AccountsLiabilities00020003Liability C
All AccountsExpenses00020000Expense A
All AccountsExpenses00020001Expense B
All AccountsExpenses00020003Expense C
All AccountsIncome00020000IncomeA
All AccountsIncome00020001IncomeB
All AccountsIncome00020003IncomeC
P&LExpenses00020000Expense A
P&LExpenses00020001Expense B
P&LExpenses00020003Expense C
P&LIncome00020000IncomeA
P&LIncome00020001IncomeB
P&LIncome00020003IncomeC

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

I have the same problem. Is the PBI file still available? I would be very happy!

Regards

Jenny

Hi,

That file is not available.  Start a new thread, explain the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Exactly what I was trying to do! Thanks

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.