Forum Discussion

SandorTS's avatar
SandorTS
New Member
1 year ago
Solved

Card visual or measure error

I want to create and show a division, but card visual shows 'Error fetching data for this visual'. Here is my code:

 

Measure =
VAR _aaa =
    CALCULATE(
        SUM('Consolidated table'[Cost]),
        'Consolidated table'[Data Source] <> "X"
    )
VAR _bbb =
    CALCULATE(
        SUM('Consolidated table'[Cost]),
        'Consolidated table'[Data Source] = "X"
    )
VAR _osszeg =
    Divide(VALUE(_aaa), VALUE(_bbb))
RETURN
_osszeg
If I return _aaa or _bbb, the card shows 44k and 332k respectively (so its numeric and visual shows it, no error).
No applied filters on the page or on the visual, no slicer sync active from other pages.
What's the problem? Thanks.

EDIT: If I replace the code for _aaa or _bbb to be 1, then osszeg shows the correct values.
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi SandorTS 

     

    Thanks for the reply from danextian .

     

    I created a sample data to do the test and everything shows up fine. If my sample data is different from the data structure you are using, then please provide some sample data and expected results based on the sample data so that we can help you better. How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.

     

    My sample:

     

    Measure:

     

    Measure = 
    VAR _aaa =
        CALCULATE(
            SUM('Consolidated table'[Cost]),
            'Consolidated table'[Data Source] <> "X"
        )
    VAR _bbb =
        CALCULATE(
            SUM('Consolidated table'[Cost]),
            'Consolidated table'[Data Source] = "X"
        )
    VAR _osszeg =
        Divide(_aaa, _bbb)
    RETURN
    _osszeg

     

     

    Output:

     

    For measure, I set it to show two decimals, sometimes the default may not show decimals, then the result will show 0.

     

     

    Also, what I need to confirm with you is whether the error is in Power BI desktop or Power BI Service? What is your data source? 

     

    If it's appearing in Service, I found a couple of posts with similar error reporting for your reference:

     

    The solution to this post is to remove the semicolon from the SQL query in the Advanced Editor.

    Solved: Couldn't load the data for this visual - Microsoft Fabric Community

     

    One solution in this post is to check the permissions of the gateway.

    Solved: Re: Error fetching data for this visual - Microsoft Fabric Community

     

    Best Regards,
    Yulia Xu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Why the need to use VALUE() when the results of the first two variables are already numeric?

    • SandorTS's avatar
      SandorTS
      New Member

      I have tried to debug it before I checked _aaa and _bbb value. You are right, VALUE() isn't needed.
      (Still not working of course)

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi SandorTS 

     

    Thanks for the reply from danextian .

     

    I created a sample data to do the test and everything shows up fine. If my sample data is different from the data structure you are using, then please provide some sample data and expected results based on the sample data so that we can help you better. How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.

     

    My sample:

     

    Measure:

     

    Measure = 
    VAR _aaa =
        CALCULATE(
            SUM('Consolidated table'[Cost]),
            'Consolidated table'[Data Source] <> "X"
        )
    VAR _bbb =
        CALCULATE(
            SUM('Consolidated table'[Cost]),
            'Consolidated table'[Data Source] = "X"
        )
    VAR _osszeg =
        Divide(_aaa, _bbb)
    RETURN
    _osszeg

     

     

    Output:

     

    For measure, I set it to show two decimals, sometimes the default may not show decimals, then the result will show 0.

     

     

    Also, what I need to confirm with you is whether the error is in Power BI desktop or Power BI Service? What is your data source? 

     

    If it's appearing in Service, I found a couple of posts with similar error reporting for your reference:

     

    The solution to this post is to remove the semicolon from the SQL query in the Advanced Editor.

    Solved: Couldn't load the data for this visual - Microsoft Fabric Community

     

    One solution in this post is to check the permissions of the gateway.

    Solved: Re: Error fetching data for this visual - Microsoft Fabric Community

     

    Best Regards,
    Yulia Xu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.