Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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?

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

You may create a measure like below and use it for the datetime visual.

Measure 2 = 
SUMX(FILTER(Table2,Table2[datetime]=MAX(Table2[datetime])),[invert])

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-cherch-msft
Employee
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

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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?

Hi @Anonymous 

 

You may create a measure like below and use it for the datetime visual.

Measure 2 = 
SUMX(FILTER(Table2,Table2[datetime]=MAX(Table2[datetime])),[invert])

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Fantastic it works thank you. Can you please explain the last measure?

 

SUMX(FILTER(Table2,Table2[datetime]=MAX(Table2[datetime])),[invert])

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.