Forum Discussion

anglefbi11's avatar
anglefbi11
Icon for Helper I rankHelper I
2 years ago

powerbi matrix visuals shows wrong numbers

hi guys

i am facing an issue with the visual for matrix table

* when i choose card visual it gives me wrong percentage

* when i change the visual to pie chart ( highlight option ) it gives me the correct value

*  when i change the visual to pie chart ( filter option ) it gave me the wrong value

 

 

kindly notice that i didnt change the measure the issue only when i change the visual . you may refer to the sceen shots

 

i need you guys to explain to me where is the issue any why this happen to me !!

 

 

 

 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi anglefbi11 ,

     

    The problem seems to be related to the filter context.

     

    The most relevant information you need to master about evaluation contexts is the difference between the row context and the filter context. You cannot appreciate any difference until you know exactly what the two contexts are.

     

    This link can help you:

    Filter context in DAX - SQLBI

     

    If you have any other questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

  • fahadqadir3's avatar
    fahadqadir3
    Icon for Solution Supplier rankSolution Supplier

    anglefbi11 Pie Chart (Highlight Option):

    When using the highlight option, the pie chart shows a portion of the data while still displaying the overall context. This means that the percentage calculation can be more accurate because it retains the full data set context, showing how much of the whole is highlighted.

     

     

    When you use the filter option, the pie chart only displays the filtered subset of the data. If the percentage appears wrong, it might be because the filter changes the context of the data, leading to a different calculation for the measure. This can result in the measure being evaluated only on the filtered data set, which may not match your expectations.

    Solution

    Here’s an example of how you might write a DAX measure to correctly handle context:

    Ensure that your measure is context-aware and correctly handles the different contexts it is evaluated in. You might need to use DAX functions such as CALCULATE, ALL, or FILTER to control how the context affects your measure.

     

    CorrectedPercentage =
    VAR TotalValue = CALCULATE(SUM(Table[Value]), ALL(Table))
    RETURN DIVIDE(SUM(Table[Value]), TotalValue, 0)

    This measure calculates the percentage of the total value regardless of filters applied, ensuring consistency across different visuals.

    Hope it works.

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!! 

    • anglefbi11's avatar
      anglefbi11
      Icon for Helper I rankHelper I

      hala fahad

      the issue as you said shows when i apply filters ( you are right )

       

      but i need small help

       

      these are my current measures how do i apply what you wrote above?

       

      i have two measuers ( one to show me the count and the second is for percentage )

       

      count = COUNTROWS('Query1')

       

      percentage = DIVIDE([count], CALCULATE( [count],ALL(Query1[Minutes (bins)])))