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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Send eMail when PowerQuery fails to update

Hi all,

I setup my xlsx file with several queries pointo to .csv files on the network.

For various reasons  it can sometimes happen that the structure of the targrt files changes (misisng column, different column name...)

 

When this occours, obviously Excel displays a <<danger>> sign beside the Query Name.

 

This was great when I was running the update myself manually and had the file open in front of me.

 

Now that I have automated the refresh of the excel file with the following PowerShell script, I am not getting any warning message anymore, even if I try to capture the messages with the try...catch function. Can an email be triggered instead from Excel?

 

Do you have any ideas?

 

And also: I am not sure this  [wb.RefreshAll()] is the best code to  refresh all queries and all pivots, any suggestions?

 

Thank you

 

 

$folderPath = "I:\Technical_Training\PUBLIC\REPORT\SF_SFTP_Data\Report_Output\PROD"
#$date = Get-Date
$dateString = Get-Date -Format "yyyyMMdd"

$doesexist = Test-Path ($folderPath + "\" + $dateString)

if($doesexist){
    Copy-Item -Force ($folderPath + "\" + $dateString + "\*") -Destination $folderPath
}else{
    Write-Host "Folder does not exits"
}
$app = New-Object -comobject Excel.Application
$app.Visible = $False
$app.DisplayAlerts = $FALSE
$wb = $app.Workbooks.Open("I:\Technical_Training\PUBLIC\REPORT\CIS_LNR\TRAINING_REPORT.xlsx")
$wb.Name
try {
    $wb.RefreshAll()
    $wb.Save()
} catch {
    $msg = $_.Exception.Message
    Send-MailMessage -From 'LMS Admin <lmsadmin@sk.com>' -To 'Luca <luca.avalle@sk.com>' -Subject 'Errors in KPI file' -SmtpServer 'mailie.skbiotek.com' -Body $msg
}

$wb.Close($false)
$app.Quit()

 

 

1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Basde on my research, we cannot achieve that in power query. However we can make it in Power bi service. Please refer to the online document.

https://powerbi.microsoft.com/en-us/blog/sending-refresh-notifications-to-others/

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

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.