Forum Discussion

JonClemo's avatar
JonClemo
Regular Visitor
6 years ago

Index chart - specifying a particular data value

I am trying to create a summary table of income for a number of organisations over a number of years, categorised by size with a base year index column. The end result would look something like this containing results for multiple years

 

 

The report is intended for reuse and update so I am trying minimise the steps if any data is refreshed or visuals changed

 

I have a table with income for each organsiation for each year

I used a switch function to create a column that categorises that data into custom bands

I created a table using summarise that groups by year column and income by band with roll-up.

 

This gives me which is correct

 

I now want to add the index column

The formula for the income index would be [income]/[income total in 2008]

 

I know I could simply hardcode in the number but wanted to reference it. What I can’t understand if how to specify the reference or query in the formula to get a specific value returned. Essentially it would be

Select income where year end = 2008 AND category is blank (or total if I knew how to name the rollup row)

Where I got to is

Index = 'Table'[Income]/(CALCULATE(sum('Table'[Income]), 'Table'[Year End] =2008, 'Table'[Size By Income] = blank()))

But this only seems to work for the 2008 total row – otherwise it seems to not get the reference and return zero.  

 

I've looked at the answer here which seems to use variables which I've not used in DAX before - what am I not seeing and what are my options? many thanks

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Creating-index-chart-showing-trend-from-the-baseline-year/m-p/725192#M1518

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JonClemo ,

     

    Can you share sample data, or a sample pbix file.

     

    Try this

    Index =
    DIVIDE (
        'Table'[Income],
        CALCULATE (
            SUM ( 'Table'[Income] ),
            'Table'[Year End] = 'Table'[Year End] - 1
        )
    )

     

    Regards,

    Harsh Nathani

    • JonClemo's avatar
      JonClemo
      Regular Visitor

      Thanks Anonymous your suggestion produces the error below - but if I have understood it correctly I think it's trying to answer something slightly different which is 'current year divided by last year' whereas I am after 'current year divided by a specified year in the past'

       

      Here is some sample data 

      Test_Index Chart.xlsx 

       

      In pulling this out I realised that the base year reference would also need to change based on the category 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi JonClemo ,

         

        How do you determine the specified year in the past.

         

        Try this.

         

        Create  a separate Year Table. Add this as a slicer. This will detremine your index value.

         

         

         

         

        Create Measures

         

         

        Total Income = SUM('Table'[Income])

         

        Selected year Index = SELECTEDVALUE(YearTable[Year End])

         

        Measure 5 = 
        var selyear = [Selected year Index]
        var sumyear = CALCULATE(SUM('Table'[Income]),FILTER(ALL('Table'[Year End]), 'Table'[Year End] = selyear))
        RETURN
        DIVIDE ([Total Income],sumyear)

         

        Regards,
        Harsh Nathani

        Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)