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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
martaredondo
Helper II
Helper II

If statement when importing excel

Hey all,

 

I have an Excel file that I need to import to Power BI once a week. The problem is that sometimes a specific sheet exists, sometimes it doesn't.

 

Is there a way to do an if statement when importing the sheet? Something like IF "SheetName" doesn't exist THEN do nothing/put only headers. I'm getting constant errors because in certain weeks Power BI can't find the sheet.

 

Thanks for you help,

Marta

 

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@martaredondo 

 

You may use Try expression to deal with it.

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-chuncz-msft
Community Support
Community Support

@martaredondo 

 

You may use Try expression to deal with it.

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft thank you so much! It works perfectly, this is exactly what I need 😁

parry2k
Super User
Super User

@martaredondo not sure how you are importing the excel file, are you reading file from a folder or what? Can you share M code?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k i'm reading the excel from sharepoint online, basic import.

 

The problem is the number of sheets in that excel is not fixed. It is an extraction from a tool our company uses and if there is no data asssociated to that export the sheet "disapears".

 

Imagine I have 2 sheets "Orders from Client A" and "Orders from Client B", if in that week I have no orders from client B the only sheet in my excel is "Orders from Client A". This is why I need to have a verification like IF "Orders fro Client B" do not exist THEN do nothing/put table in blank

@martaredondo gotcha, stay tuned.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

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.