Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Dynamic Rebasing Chart

Hello there,

 

I found this very similar question but I cant seem to find the solution and figure out how to edit - Old Case 

 

Similar to it, I am using a slicer to show the start and end date for a chart where the Start Date will also be used as the rebasing date. I have the codes below derived from a quick measure but I am not getting the correct chart.. My expectation is it should be indexed at 100 on the Start Date from the slider. I would appreciate your help as I am new to DAX.

 


Return =
VAR __BASELINE_VALUE =
    CALCULATE(
        SUM('PH Equity Indices'[Value]),
        ALLSELECTED('PH Equity Indices'[Date])
    )
VAR __MEASURE_VALUE = SUM('PH Equity Indices'[Value])
RETURN
    IF(
        NOT ISBLANK(__MEASURE_VALUE),
        DIVIDE(__MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE)+100
    )

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Sorry, having trouble following, can you post sample data as text and expected output?
    Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Community Support

    Hi Anonymous ,

     

    Do you want to display the 100 in the min date?

    If yes, we can create a date table and a measure to meet your requirement.

     

    1. Create a date table that has no relationship.

     

    Date = CALENDAR("2020/1/1","2020/1/31")

     

     

    2. Then we can create a measure.

     

    Measure = 
    var _min = MIN('Date'[Date])
    var _max = MAX('Date'[Date])
    return
    IF(
        MAX('Table'[Date]) = _min,100,
        CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]<=_max && 'Table'[Date] >=_min)))
    

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

     

    Best regards,

     

    Community Support Team _ zhenbw

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

     

    BTW, pbix as attached.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-zhenbw-msft thank you so much! Although the calculation in your pbix seems to be incorrect? I would expect the higlighted results below if I choose Jan 1 2020 as the Start Date.