Forum Discussion

PowerBI_freak_1's avatar
PowerBI_freak_1
Frequent Visitor
1 month ago
Solved

Power BI Service Excel Export Fails When Using System.TimeZoneInfo.ConvertTimeFromUtc in RDL Express

I have an RDL file with approximately 800,000 rows. When I use the following expression in a textbox, I can successfully export the report to Excel from the Power BI Service: ="Number of rows expo...
  • tanishabhawsarr's avatar
    1 month ago

    This is most likely due to a Power BI Service sandbox limitation rather than an issue with your expression itself.

    System.TimeZoneInfo.FindSystemTimeZoneById() and System.TimeZoneInfo.ConvertTimeFromUtc() rely on the underlying .NET runtime and Windows time zone registry. In Power BI Report Builder (running locally), these APIs have access to the local OS configuration, so the export succeeds. However, in the Power BI Service, paginated reports run in a managed environment where certain .NET methods and time zone resources may not be fully supported during rendering/export, which can lead to the generic "Export failed" error.

    As a workaround, instead of using:

    System.TimeZoneInfo.ConvertTimeFromUtc(
        System.DateTime.UtcNow,
        System.TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")
    )

    you could:

    1. Use a dataset field (GENERATED_ON) populated by SQL and perform the timezone conversion in the query itself:

    SELECT SYSDATETIMEOFFSET() AT TIME ZONE 'Pacific Standard Time' AS GENERATED_ON_PST

    1. Or, if DST handling is not critical, use a simple offset:

    =Format(DateAdd("h", -8, System.DateTime.UtcNow),
           "dd-MMM-yyyy hh:mm tt") & " PST"

    1. Another option is to use the built-in report execution time:

    =Format(Globals!ExecutionTime,
           "dd-MMM-yyyy hh:mm tt")

    and convert it in the source query if a specific timezone is required.

    I'd recommend moving the timezone conversion to the data source (SQL) whenever possible, as it's generally more reliable for Power BI Service exports and avoids differences between the local Report Builder environment and the Service rendering engine.

    Has anyone else seen TimeZoneInfo methods fail specifically during Power BI Service Excel exports? It would be interesting to know whether this is an undocumented limitation or a recent regression.