Forum Discussion

AndrewPF's avatar
AndrewPF
Icon for Helper V rankHelper V
4 years ago
Solved

display chart only when something else is filtered

My pseudodata looks like this: 

group item no. total sales
A 100 1250
A 110 48909
A 120 56015
B 220 6105
B 230 50189
B 245 15199
C 309 1016
C 308 1099
C 366 1019
etc.

and I want to put it on a chart, but I only want to show a single group at a time. 

I have a "group" slicer, a new measure: 

Total sales = if(isfiltered(DATASOURCE[group]), calculate(sum(DATASOURCE[Total sales])), 0)

and a chart which displays "Total sales" by "item no.".

This all works fine when I have selected something in the "group" slicer, but I want the chart to be blank unless something is selected.  At the moment, if nothing is selected in the "group" slicer, the chart contains everything i.e. all my item no.s, with blanks in every "Total sales". 

I can add a filter to the chart itself so that it only displays in the chart if sales is > 0, but ideally I want zero sales too. 

Any ideas? 

  • HI  AndrewPF ,

    Pls test the below:

    isfilter = CALCULATE (IF ( ISFILTERED ( 'Table'[Group] ), 1, 0 ),
        ALLSELECTED ( 'Table')
    )

    Out put result:

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

     

    Best Regards,
    Lucien

3 Replies

  • AndrewPF , Put a visual level filter for below measure =1

     

    isfilter = int(if(isfiltered(DATASOURCE[group]), allselected()) )

  • I think I get where you're coming from this, but I get the error message: 

    "The Expression Refers to Multiple Columns. Multiple Columns Cannot Be Converted to a Scalar Value."

  • v-luwang-msft's avatar
    v-luwang-msft
    Icon for Community Support rankCommunity Support

    HI  AndrewPF ,

    Pls test the below:

    isfilter = CALCULATE (IF ( ISFILTERED ( 'Table'[Group] ), 1, 0 ),
        ALLSELECTED ( 'Table')
    )

    Out put result:

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

     

    Best Regards,
    Lucien