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

Current vs Previous value, not dependent on base value

Hi,

 

I'm wondering if there's a way for me to have a chart displaying one value over time, with a bar below showing the difference between the current and previous value, BUT i want to be able to change the base value between different values?

 

Let's say I have 15 different sets of values that I want to present this way, so instead of me making 15 different calculated measures, one for each value, I wonder if there's some sort of way for me to make a column/measure or something that does what I'm after? And then I can just click and change between the values that I want.

 

The only constant are the time values. 

 

Hope this made any sense and thanks for any help.

 

To clarify: Ability to switch between different values to present both line for values and bars for increase or decrease of the value. 

 

Thanks

1 ACCEPTED SOLUTION

Hi @Anonymous

 

I gave you some erroneous code previously (I hadn't tested it - i was making extrapolations from other similar work I've done, but I had some false assumptions).

 

Points 1-3 in the above reply still hold - please review them.  However, now we need to modify the measures.

 

For transparency, we'll use 3 measures. I'll talk about where they can be combined afterwards

 

TodaysValue= 
    SWITCH(
        [MType];
        "BJ-HÖ1"; AVERAGE(Blad1[BJ-HÖ1]);
        "BJ-MÄ"; AVERAGE(Blad1[BJ-MÄ]);
        "BJ-TS1"; AVERAGE(Blad1[BJ-TS1]);
        etc
    )

PrevDayValue = CALCULATE([TodaysValue]; PREVIOUSDAY(DateTimeTab[Date]))

Measure Delta = [TodaysValue] - [PrevDayValue]

The mistake was thinking we could store some of the complex code in variables and use the code again further down in the measure.  I think we can really only have a minimum of 2 measures, unless you want to replicate a lot of code:

 

TodaysValue= 
    SWITCH(
        [MType];
        "BJ-HÖ1"; AVERAGE(Blad1[BJ-HÖ1]);
        "BJ-MÄ"; AVERAGE(Blad1[BJ-MÄ]);
        "BJ-TS1"; AVERAGE(Blad1[BJ-TS1]);
        etc
    )

Measure Delta = 
//NOTE That variables are not needed here - just showing for illustrative purposes VAR __Todaysvalue = [TodaysValue]
VAR __PrevValue = CALCULATE([TodaysValue], PREVIOUSDAY(DateTimeTab[Date]) RETURN __Todaysvalue - __PrevValue

//You could do the following without any variables and get the same results
//Measure Delta = [TodaysValue] - CALCULATE([TodaysValue], PREVIOUSDAY(DateTimeTab[Date])

Hope this finally gets you to where you need to be.  Sorry for the earlier confusion.

 

David

View solution in original post

24 REPLIES 24
Anonymous
Not applicable

Hi again, for some reason, some of the value-series can't be selected. Eventough they are very similiar to the other values. I just get a blank screen

Check that the data for the value names doesn't have white space or special characters.  The match needs to be exact with what you put in the SWITCH() statement.

Anonymous
Not applicable

Thank you so much for the time and effort you put into this, 

I will check this out!

 

Thanks and merry christmas! 

Anonymous
Not applicable

Thank you for the help, I'll try your solution when I'm working on this next.

 

Best regards 

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.

Top Solution Authors