Forum Discussion

Michael_Gold's avatar
Michael_Gold
Frequent Visitor
4 years ago

Default value for KPI if no date is selected

Hello,

 

I'm trying to create a KPI card that will present as default the previous calendar month goal and score, but when a date or period is selected (from the Dates table), then it will show the data for the chosen period of time

 

To present the previous month score (later will apply the same on target) as default, and the selected month score otherwise, I've created a column in the 'Dates' table to present the previous month then tried to build a measure as follows:

 

Indicator =

VAR PrevMonth =
MAX(Dates[PrevMonth])

VAR MonthToPresent =
IF(
ISBLANK(
SELECTEDVALUE(Dates[Month_Year])),
PrevMonth,
SELECTEDVALUE(Dates[Month_Year])
)

VAR ScoreToPresent =
CALCULATE(
AVERAGE(
Score[Score]
),
Dates[Month_Year] = MonthToPresent
)

RETURN ScoreToPresent

 

The measure by itself works, it presents the previous month score if there is no selected date

However when applying it to a KPI card, the result is different and I can't figure out how to solve this

 

Also, how can I copy the same logic to present the score of a selected period?

 

 

 

Here is the file:

https://drive.google.com/file/d/1l-ayAskzZm7HTKHlqUl3Gv1wCW7A8IfQ/view?usp=sharing

 

Thanks,

Michael

1 Reply

  • The KPI card doesn't know what you mean by "selected value", it panics and picks the maximum date (or whatever aggregation you specify).  You will need to be more specific, for example by having a slicer that holds your date target, and that you can then query with ISFILTERED or FILTERS.

     

    Most likely this will lead to a worse UX though, and may not be what your users want.