Forum Discussion

j_ocean's avatar
j_ocean
Helper V
1 year ago
Solved

SELECTEDVALUE, HASONEVALUE not Recognizing Small Multiples

I have a DAX measure that works perfectly to obtain a filtered value in a matrix visual.

Converting the matrix to a stacked bar chart with one of the variables used for small multiples, the expression simply does not recognize the implicit measure of the small multiples. It DOES recognize the implicit filter in a matrix, or explicit in a slicer. This measure is used as a constant line (in the analysis tab) to return the total of one bar across all bars, for reference. All columns used are on the same table.

 

The code at issue is 

VAR x = SELECTEDVALUE(table[col]),"Default") RETURN.... 

 

I tested this by using a new measure

DISTINCTCOUNT(table[col]) * (a constant to make it visible) 

and the result was the total, unfiltered number of possibilities (*the constant) ignoring the small multiple, confirming it is indeed the small multiple implicit filter not being passed to DAX measures vs a problem with my specific DAX measure.

 

Does anyone have a workaround besides just making multiple separate visuals with locked filters and ditching small multiples altogether?

  • I don't think that there will be any way to get this working with small multiples. If you look at the DAX queries generated for the visual, when the measure for the constant line is evaluated it is done in an evaluation context which does not include the column you use to separate the small multiples, so because it is not being filtered at all there is no way to determine which multiple you are currently in.

    My guess is that this is by design for performance reasons. As it is a constant line then the categories should have no impact on its value, and it is only calculated once for the entire visual, rather than having to be calculated multiple times when it should produce the same value.

5 Replies

  • sounds like a fun problem to investigate.

     

    Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
    Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
    Please show the expected outcome based on the sample data you provided.

    Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi j_ocean ,

    Based on the description, try using ISFILTERED function to check if the column is being filtered.

    VAR x = IF( ISFILTERED(table[col]), SELECTEDVALUE(table[col], "Default"), "Default" ) RETURN

    If the function doesn't work, perhaps multiple separate views need to be made.

    You can also view the following document to learn more information.

    ISFILTERED function (DAX) - DAX | Microsoft Learn

     

    Best Regards,

    Wisdom Wu

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

    • j_ocean's avatar
      j_ocean
      Helper V

      This did not change the behavior of the line but I appreciate the attempt.

  • I don't think that there will be any way to get this working with small multiples. If you look at the DAX queries generated for the visual, when the measure for the constant line is evaluated it is done in an evaluation context which does not include the column you use to separate the small multiples, so because it is not being filtered at all there is no way to determine which multiple you are currently in.

    My guess is that this is by design for performance reasons. As it is a constant line then the categories should have no impact on its value, and it is only calculated once for the entire visual, rather than having to be calculated multiple times when it should produce the same value.

    • j_ocean's avatar
      j_ocean
      Helper V

      I think you are correct, but that seems like a weakness in the design to just assume the small multiple doesn't affect the constant. In this case the constant line does differ based on the small multiple, the point is to showmultiple versions of the same analysis with a slightly varying assumption represented by the line. 

      I've moved to just making individual visuals with a locked filter.