Forum Discussion

wangjian's avatar
wangjian
Icon for Microsoft Employee rankMicrosoft Employee
6 years ago
Solved

Slicer issue with stacked column chart

I have a table, which mainly has two columns, 

Table

CountColumn  ServiceColumn

1                       serviceA

2                       serviceB

3                       serviceC

4                       serviceD

 

I have a stack column chart, which X-axis is ServiceColum, Y-axis is CountColumn

I want to use ServiceColumn as my slicer.

 

In this example, I have 4 service, which is serviceA  serviceB  serviceC  serviceD

By default, if none in the slicer selected, it will show all 4 service in my stacked column chart.

And if I select one of the service in the slicer, it will only show one column in  my stacked column chart.

 

Now, my question is how to make this happen: If none in the slicer selected, I want to have a default column, let's default column is serviceB.

 

I try to do this, create a measure 

Measure 2 = if(ISFILTERED(JianTest[ServiceTag]), 1, 0 )  and apply this measure as a filter into stacked column chart.
if Measure 2 is 0, then aplply this filter. but it failed.
 
Could anyone help me with this?
 
Thanks
  • Hi, wangjian 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table:

     

    Test(a calculated table):

    Test = DISTINCT('Table'[ServiceColumn])

     

    There is no relationship between two tables. You may create a measure as below.

    Visual Control = 
    IF(
        ISFILTERED(Test[ServiceColumn]),
        IF(
            SELECTEDVALUE('Table'[ServiceColumn]) in DISTINCT(Test[ServiceColumn]),
            1,0
        ),
        IF(
            SELECTEDVALUE('Table'[ServiceColumn])="serviceB",
            1,0
        )
    )

     

    Finally you may put the measure in the visual level filter and use the 'ServiceColumn' from 'Test' table to filter the 'Stacked column chart'.

     

     

    Best Regards

    Allan

     

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

     

     

     

3 Replies

  • wangjian , Not very clear try like

    new measure =

    if(isfiltered(Table[ServiceColumn]), calculate(count(Table[Countcolumn]), filter(Table,Table[ServiceColumn] ="serviceB")),count(Table[Countcolumn]))

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

    Hi, wangjian 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table:

     

    Test(a calculated table):

    Test = DISTINCT('Table'[ServiceColumn])

     

    There is no relationship between two tables. You may create a measure as below.

    Visual Control = 
    IF(
        ISFILTERED(Test[ServiceColumn]),
        IF(
            SELECTEDVALUE('Table'[ServiceColumn]) in DISTINCT(Test[ServiceColumn]),
            1,0
        ),
        IF(
            SELECTEDVALUE('Table'[ServiceColumn])="serviceB",
            1,0
        )
    )

     

    Finally you may put the measure in the visual level filter and use the 'ServiceColumn' from 'Test' table to filter the 'Stacked column chart'.

     

     

    Best Regards

    Allan

     

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