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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Append queries based on excel cell values.

I have some queries and I append all queries into a Master query.

SS23_LL_LP + AH23_LL_LP + SS24_LL_LP = MasterChartLL

But I want that MasterChartLL will be appended based on the Excel table. 

 

My requirement: 

I have an excel table like the below picture.

If the Excel chart is updated SS23, AW23 then, 

MasterChartLL will append SS23_LL_LP + AH23_LL_LP

 

Or

 

If In Excel chart, is updated with SS23, and SS24 then, 

MasterChartLL will append SS23_LL_LP + SS24_LL_LP

 

How can I dynamic append queries based on excel data? 

 

MohsinBipu_0-1678876422865.png

 

 

1 ACCEPTED SOLUTION
ams1
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

They say "eval is EVIL", but in PowerQuery it's an angel 👼!

 

Given:

ams1_0-1679062466371.png

...and TLSeasonFilter is:

ams1_1-1679062505742.png

WHEN MasterChartLL is:

 

let
    Source = TLSeasonFilter,
    #"Added WithSuffix" = Table.AddColumn(Source, "WithSuffix", each [Season] & "_LL_SP"),
    //                                                                          ^^^^^^^^ - all have same suffix, right?
    #"Removed Other Columns" = Table.SelectColumns(#"Added WithSuffix", {"WithSuffix"}),
    TableToList = Table.ToList(#"Removed Other Columns"),
    listOfTables = List.Accumulate(
        TableToList, {}, (final, current) => List.Combine({final, {Expression.Evaluate(current, #shared)}})
    ),
    ret = Table.Combine(listOfTables) // assumes all tables have same header
in
    ret

 

Then you should get what you want - if I understood it correctly. 😉

 

Please mark this as ANSWER if it helped.

 

P.S.: currently the TLSeasonFilter controls what tables get appended. If you want SS24_LL_LP to be always present, just add it to the List.Accumulate seed: instead of "{}", use "{Expression.Evaluate("SS24_LL_SP", #shared)}"

View solution in original post

7 REPLIES 7
ams1
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

They say "eval is EVIL", but in PowerQuery it's an angel 👼!

 

Given:

ams1_0-1679062466371.png

...and TLSeasonFilter is:

ams1_1-1679062505742.png

WHEN MasterChartLL is:

 

let
    Source = TLSeasonFilter,
    #"Added WithSuffix" = Table.AddColumn(Source, "WithSuffix", each [Season] & "_LL_SP"),
    //                                                                          ^^^^^^^^ - all have same suffix, right?
    #"Removed Other Columns" = Table.SelectColumns(#"Added WithSuffix", {"WithSuffix"}),
    TableToList = Table.ToList(#"Removed Other Columns"),
    listOfTables = List.Accumulate(
        TableToList, {}, (final, current) => List.Combine({final, {Expression.Evaluate(current, #shared)}})
    ),
    ret = Table.Combine(listOfTables) // assumes all tables have same header
in
    ret

 

Then you should get what you want - if I understood it correctly. 😉

 

Please mark this as ANSWER if it helped.

 

P.S.: currently the TLSeasonFilter controls what tables get appended. If you want SS24_LL_LP to be always present, just add it to the List.Accumulate seed: instead of "{}", use "{Expression.Evaluate("SS24_LL_SP", #shared)}"

Anonymous
Not applicable

From this step, this is not working. Before, all steps are working. I think, Need to change something. Please advise. Not an expert in M language. 😞 

 

MohsinBipu_0-1679124998366.png

 

 

 

ams1
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

Can you please share the error?

Anonymous
Not applicable

Ohhh, Sorry, My mistake. I have found the reason.  Basically, I update the excel wrong and There are no Power query exists. that's why This error is coming. Anyhow, can I avoid this error with  formula update, like if no query exists as per the excel update, then the formula will avoid those query?

MohsinBipu_1-1679289240663.png

 

ams1
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

First of all, if it worked and it helped, please mark my first reply as answer 🤗

Second, I think you can put a "try" before Expression.Evaluate... and after an "otherwise null" - and see if it works.

Anonymous
Not applicable

something like below?

 

let
    Source = TLSeasonFilter,
    #"Added WithSuffix" = Table.AddColumn(Source, "WithSuffix", each [Season] & "_LL_SP"),
    //                                                                          ^^^^^^^^ - all have same suffix, right?
    #"Removed Other Columns" = Table.SelectColumns(#"Added WithSuffix", {"WithSuffix"}),
    TableToList = Table.ToList(#"Removed Other Columns"),
    listOfTables = List.Accumulate(
        TableToList, {}, (final, current) => List.Combine({final, {try Expression.Evaluate(current, #shared)} otherwise null})
    ),
    ret = Table.Combine(listOfTables) // assumes all tables have same header
in
    ret

 

 

ams1
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

Something like:

let
    Source = TLSeasonFilter,
    #"Added WithSuffix" = Table.AddColumn(Source, "WithSuffix", each [Season] & "_LL_SP"),
    //                                                                          ^^^^^^^^ - all have same suffix, right?
    #"Removed Other Columns" = Table.SelectColumns(#"Added WithSuffix", {"WithSuffix"}),
    TableToList = Table.ToList(#"Removed Other Columns"),
    listOfTables = List.Accumulate(
        TableToList, {}, (final, current) => List.Combine({final, {try Expression.Evaluate(current, #shared) otherwise null}})
    ),
    ret = Table.Combine(listOfTables) // assumes all tables have same header
in
    ret

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.