Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Adjust values based on slicer state

I have a dataset with time series, a value, and a location.

 

datetimevaluelocation
26-2-2019 12:154A
26-2-2019 12:3023A
26-2-2019 12:452A
26-2-2019 13:0062A
26-2-2019 13:153A
26-2-2019 12:156B
26-2-2019 12:3045B
26-2-2019 12:458B
26-2-2019 13:008B
26-2-2019 13:152B
26-2-2019 12:153C
26-2-2019 12:304C
26-2-2019 12:454C
26-2-2019 13:006C
26-2-2019 13:154C

 

This data is about electricity meters.

For these time series a have a bar/line chart for the sum(value) of all locations per time interval.

And a bar chart with sum(value) per location.

For analysis purposes, I want to be able to invert the value (value * -1) per location.

Ideally, I can use a standard slicer visual, with a list of all the locations, if a location is unselected the data shown is normal, if a location is selected the data for only the selected locations are inverted (value * -1) and the data is not filtered like the default behaviour of a slicer.

 

Any ideas?

4 Replies

  • v-cherch-msft's avatar
    v-cherch-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Anonymous 

     

    You may create a slicer table: Slicer = DISTINCT(Table2[location]).Then use it as slicer.Then you may get the measure like below:

    invert = 
    IF (
        MAX ( Table2[location] ) in VALUES(  Slicer[location] ),
        SUM ( Table2[value] ) * ( -1 ),
        SUM ( Table2[value] )
    )
    

    Regards,

    Cherie

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-cherch-msft 

       

      Thank you. But it doesnt seem to work like i want yet.

      In the example pbix you attached;

      * if i select no location (ie all values should be original) then all values are * -1. it does work correctly if one or more locations are selected. i managed to fix this myself by putting your code into an IF ISFILTERED

      * if i make a column chart with "datetime" on the axis, and "invert" on the values, then it does not behave like i expected. this chart is the ultimate goal of my report. i guess that is because location is not in the chart? is there a way around this?

       

      Bonus question:

      The slicer table does not seem to respond to filters. Is that possible? What if there was more data and because of an (external) filter there were less locations?