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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

It is possible to indicate power query that depending on a parameter load or not a table?

 

I am facing this problem sometimes so i would like to know if any of you could help me. 

My doubt is about loading data depending on a parameter. I mean.. i have to load an excel file and that works fine, the problem is that sometimes i will have to add another excel file (but not always!). That's the problem..sometimes i have 1 excel and another one 2 so i would like to add a parameter that indicate when i have one or two and depending on this load 1 or two excels files. 

It will be something like: 

IF parameter = 1 --> Load 1 and 2

IF parameter = 0 --> Load only 1 

Not sure if it's possible.. 

 

Thank you in advance. 

 

Andrea.

 

1 ACCEPTED SOLUTION
artemus
Employee
Employee

You could replace the second table with an empty table when it is missing.

 

Let's say you have 2 queries that you load. Then you union them into the final table.

 

In this case, add a custom step to your second query:

 

try #"Previous Step" otherwise #table(type table [], {})

 

Note that if you load the second table by itself into the model, it will be removed when it is not there, potentially breaking any visuals that depend on it, and removing any relationships. If instead you the second table to be empty then:

 

try #"Previous Step" otherwise #table(Value.Type(OtherTable), {})​

where OtherTable is the name of your first query. Also, if you do a Combine tables, you will need to do it in a new query instead of ontop of your first one.

View solution in original post

1 REPLY 1
artemus
Employee
Employee

You could replace the second table with an empty table when it is missing.

 

Let's say you have 2 queries that you load. Then you union them into the final table.

 

In this case, add a custom step to your second query:

 

try #"Previous Step" otherwise #table(type table [], {})

 

Note that if you load the second table by itself into the model, it will be removed when it is not there, potentially breaking any visuals that depend on it, and removing any relationships. If instead you the second table to be empty then:

 

try #"Previous Step" otherwise #table(Value.Type(OtherTable), {})​

where OtherTable is the name of your first query. Also, if you do a Combine tables, you will need to do it in a new query instead of ontop of your first one.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors