Forum Discussion
Index chart - specifying a particular data value
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)
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
- JonClemo6 years agoRegular Visitor
Thanks Anonymous
I'll have a watch. It's not the function of the formula that I am having trouble understanding I guess it is the way the variable works.
As per your illustration - table has 100 rows, this is filtered to five then summed, which gives a value say 75. I am expected that value to then be set. As a result in the second part, each and every row will have the income for that row divided by 75.
What is happening is as per your explanation is baseline only has a value for those five rows.