Forum Discussion
Index chart - specifying a particular data value
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
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
In pulling this out I realised that the base year reference would also need to change based on the category
- Anonymous6 years agoNot 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)- JonClemo6 years agoRegular Visitor
Hi Anonymous That is certainly getting me a result so thank you - just need to do a little bit more testing to check the right figures are coming out. There is however something I don't understand. If I try and do this in the data table rather than as a table in the visual I feel I should be able to create a calculated column that provides the index. Simplifying without the slicer I used
Test1 = var index_year = 2008 var Baseline = calculate(SUM('Table'[Income]), FILTER(ALL('Table'[Year End]), 'Table'[Year End] = index_year)) RETURN DIVIDE('Table'[Income], [Baseline])The result is I get a result of 1 in the column for all rows where Year End = 2008 but an empty field for all others. This implies to me that for 2008 it is calculating the Baseline variable correctly but in other years a value isn't being returned. I'm assuming this has to do with the variable being calculated by looking per row so when it filters for a 2008 value for rows other than 2008 nothing is returned but I feel I should be able to somehow set it to filter off the whole table. Any pointers would be helpful as I'm trying to improve my understanding not just copy solutions!
- Anonymous6 years agoNot applicable
Hi JonClemo ,
Based on what I have understood:
Your index is dynamic and changes based on the year you select in a slicer. Table store static values and cannot generate dynamic values. Calculated Columns work best when you want to categorise or want to eat up on your memory.
Suggest see this video :
https://www.youtube.com/watch?v=03E0f-RyRn4
https://www.youtube.com/watch?v=xV-KwuSDFMQ
https://www.youtube.com/watch?v=DwuAypulTLA
Test1 = var index_year = 2008 var Baseline = calculate(SUM('Table'[Income]), FILTER(ALL('Table'[Year End]), 'Table'[Year End] = index_year)) RETURN DIVIDE('Table'[Income], [Baseline])Will try my best to explain in simple terms. I hope i make sense.
Check the Filter Part -> You are filtering the table column [Year End] where Table[Year End] = 2018. So this will give you only rows of the table where year end = 2018. So incase your table has 100 rows out of which 5 rows are 2018. these 5 rows will be returned.
Post that you are adding the income in these 5 rows.
Now you are dividing the Income of all rows with the baseline (baseline has values only for 5 rows). So for other rows it is income divide by blank. And for 2018, you get 1. Now change the column type to decimal you may get 0.xx values in rows where year is 2018.
I hope this made sense.
Regards,
Harsh Nathani