Power Query - Skip query based on condition

35 views Asked by At

I am querying data from a DWH in Power Query in Excel and want to skip the refreshing of a specific query if a condition (idx = 1) is not fulfilled. This is the query:

`let 

  scenario = scenario_current,

  _multiregion = List.Combine({Record.ToList(superregions_record), Record.ToList(subregions_record),    {"-1"}}),
  multiregion = Text.Combine(_multiregion, ","),

  source = Excel.CurrentWorkbook(){[Name="last_year"]}[Content],
  FirstRow = Table.FirstN(source, 1),
  lfy = Text.From(FirstRow{0}[Column1]),

 Data= if idx = "1" 
       then Odbc.Query("dsn=Redshift", "
       *complex sql query using scenario, multiregion and lfy*
       ")

else "Not relevant in this case"

in Data`

My problem is just when idx != 1. Just refreshing this query finishes fast (<1 second as expected) but if I refresh all data, Excel gets stuck on this query for several minutes. I assume this has to do with some dependencies with other queries, but other queries have the same structure (using an SQL query with scenario and multiregion) refresh much faster.

Is there an explanation this takes much longer when refreshing all queries compared to refreshing only this one?

0

There are 0 answers