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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
bidev
Frequent Visitor

How to check if a file exists

I have a code that looks the file exists or not before doing further processing.  Result of "try Source" evaluation, Test[HasError] in if statement returns "False" always, whether or not there was a file "MyLog.log" in  the path "C:\Log-Files\Empty-LogFolder\".

Appreciate if you can shed some light on it.  Code below.  Thank you.   

 

***********************************

let
    File_Path = "C:\Log-Files\Empty-LogFolder\MyLog.log",
    Source = Csv.Document(File.Contents(File_Path),[Delimiter=";", Columns=3, Encoding=1252, QuoteStyle=QuoteStyle.None]),
   Test = try Source,
   Output = if Test[HasError] then "True" else "False"
in
   Output

1 ACCEPTED SOLUTION
ankitpatira
Community Champion
Community Champion

@bidev Check out this post which describes on writing IF ELSE statement in power query.

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

HI,

The link is 404. Is there a link on microsoft ?

ankitpatira
Community Champion
Community Champion

@bidev Check out this post which describes on writing IF ELSE statement in power query.

Thank you, ankitpatira.  Appreciate your help.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors