Forum Discussion
KPI indicator visual not working properly
Hi All,
I have data as below sample for multiple students & their years & subjects-
| Student name | Year | Subject | Value |
| A | 2018 | A1 | 15 |
| A | 2018 | A2 | 39 |
| A | 2018 | A3 | 41 |
| A | 2018 | A4 | 41 |
| A | 2018 | A5 | 47 |
| A | 2019 | A1 | 25 |
| A | 2019 | A2 | 30 |
| A | 2019 | A3 | 32 |
| A | 2019 | A4 | 33 |
| A | 2019 | A5 | 23 |
| A | 2021 | A1 | 49 |
| A | 2021 | A2 | 38 |
| A | 2021 | A3 | 14 |
| A | 2021 | A4 | 19 |
| A | 2021 | A5 | 24 |
I have created below measures to get the scoring of a specific subject (A1) for recent year & 2nd most recent year-
I have created visuals on the screen as below-
1) Slicer for Student name
2) KPI indicator to get the recent value, difference between recent value & 2nd most recent value & trend of three years
The issue is the difference is being shown as infinity. Ideally the difference should come as below which I get when I remove Year value from 'Trend Axis' field. But when I add it to see the trend of three years, its giving incorrect difference as above.
If we put the measures on card as below, we can see they are showing correct recent and 2nd most recent value of Subject A1 for selected student but when we add Year value in 'Trend Axis' its all leading to issue.
Pls help on how to get the trend added in KPI card along with recent value & difference with 2nd most recent value shown on KPI indicator?
This has to do with context, your measure altough giving correct results when you have the measure with the year selection you get the result below:
Has you can see the value returns the 25 however in the yearly value it gives blank, in the KPI card since you don't have the year (except on the trend) the calculation is done with blank value so 49 / blank is infinity
If you redo your measure to:
2nd most recent yar value = CALCULATE ( SUM ( Sheet4[Value] ), FILTER ( ALLSELECTED( Sheet4), Sheet4[Year] = CALCULATE ( MAX ( Sheet4[Year] ), FILTER ( ALLSELECTED(Sheet4), Sheet4[Year] < MAX ( Sheet4[Year] ) ) ) ), Sheet4[Subject] = "A1" )Using the ALLSELECTED this will solve your issue:
You can also simplify the measure to:
2nd most recent yar value = SUMX ( TOPN ( 1, FILTER ( ALLSELECTED ( Sheet4 ), Sheet4[Year] < MAX ( Sheet4[Year] ) && Sheet4[Subject] = "A1" ), Sheet4[Year], DESC ), Sheet4[Value] )
1 Reply
- MFelixSuper User
This has to do with context, your measure altough giving correct results when you have the measure with the year selection you get the result below:
Has you can see the value returns the 25 however in the yearly value it gives blank, in the KPI card since you don't have the year (except on the trend) the calculation is done with blank value so 49 / blank is infinity
If you redo your measure to:
2nd most recent yar value = CALCULATE ( SUM ( Sheet4[Value] ), FILTER ( ALLSELECTED( Sheet4), Sheet4[Year] = CALCULATE ( MAX ( Sheet4[Year] ), FILTER ( ALLSELECTED(Sheet4), Sheet4[Year] < MAX ( Sheet4[Year] ) ) ) ), Sheet4[Subject] = "A1" )Using the ALLSELECTED this will solve your issue:
You can also simplify the measure to:
2nd most recent yar value = SUMX ( TOPN ( 1, FILTER ( ALLSELECTED ( Sheet4 ), Sheet4[Year] < MAX ( Sheet4[Year] ) && Sheet4[Subject] = "A1" ), Sheet4[Year], DESC ), Sheet4[Value] )