Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 months ago
Solved

PowerBI Expression Evaluation Thread Delegation

I am working on locale-aware formatting using a custom C# helper, whose DLL is referenced in the report server.

I am updating the Thread Culture to the specific culture so that the ToString() can format the datetime and amount correctly.
I didn't want to use ToString(format, CultureProvider) as this is slower than ToString() and can take more time to load the data if the report contains 100k or more rows.

I set the ThreadCulture in the constructor of my helper class and create an instance of it in the report. I am using this approach to have a centralised formatting helper and have control over it.

Is it possible that the report may delegate the expression evaluation to a different Thread?

  • Hi Anonymous ,

    Thank you for confirming. Since you are using Power BI Report Server, please note that it operates on the same report processing engine as SSRS. With this engine, report expressions may be evaluated across multiple threads, depending on how the report is processed and rendered. As a result, changes to Thread.CurrentThread.CurrentCulture may not persist throughout all expression evaluations.

     

    While setting the thread culture in a custom helper might sometimes work, it is not a reliable or supported solution in Power BI Report Server.

     

    For consistent and predictable formatting, it is best to explicitly specify the culture when formatting values, such as by using ToString or by passing the culture to your helper methods.

     

    I hope this clarifies the situation. If I’ve misunderstood any part of your situation, please let us know.

     

    Regards,

    Yugandhar.

6 Replies

    • V-yubandi-msft's avatar
      V-yubandi-msft
      Community Support

      Thank you for your response, and we appreciate you staying engaged with the community moving forward.

  • Hi Anonymous ,

    Thanks for reaching out to the Fabric Community. Just to clarify and better understand the scenario, are you trying this in SSRS?

     

    Regards,

    Yugandhar.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I am using PowerBI Report Server

      • V-yubandi-msft's avatar
        V-yubandi-msft
        Community Support

        Hi Anonymous ,

        Thank you for confirming. Since you are using Power BI Report Server, please note that it operates on the same report processing engine as SSRS. With this engine, report expressions may be evaluated across multiple threads, depending on how the report is processed and rendered. As a result, changes to Thread.CurrentThread.CurrentCulture may not persist throughout all expression evaluations.

         

        While setting the thread culture in a custom helper might sometimes work, it is not a reliable or supported solution in Power BI Report Server.

         

        For consistent and predictable formatting, it is best to explicitly specify the culture when formatting values, such as by using ToString or by passing the culture to your helper methods.

         

        I hope this clarifies the situation. If I’ve misunderstood any part of your situation, please let us know.

         

        Regards,

        Yugandhar.

  • Hi Anonymous ,

    If you have time, please review my previous response and let us know if any additional details or clarification are needed.

     

    Thank you.