Forum Discussion
vtechBI
Helper I
2 years agoCalculate quaterly KPI Based on Slicer Selection
Hello Colleages, kindly assist with DAX calculation for the following; 0.25 is given to calculate Q1 KPI , 0.5 is given to calculate Q2 KPI, 0.75 is given to calculate Q3 KPI, 0.1 is given to c...
Anonymous
2 years agoNot applicable
Hi vtechBI
For your question, here is the method I provided:
Here's some dummy data
"Table"
First, create calculated columns and query the year and quarter.
quarter = RIGHT('Table'[Reporting Period], 2)
year = LEFT('Table'[Reporting Period], 4)
Create measures. Set values according to different quarters. and calculate KPI.
value =
VAR quarter = SELECTEDVALUE('Table'[quarter])
RETURN
SWITCH(TRUE(),
quarter = "Q1", 0.25,
quarter = "Q2", 0.5,
quarter = "Q3", 0.75,
quarter = "Q4", 0.1,
BLANK()
)
result =
var total_ex =
CALCULATE(
SUM('Table'[Expenditure]),
FILTER(
ALL('Table'),
'Table'[Reporting Period] = MAX('Table'[Reporting Period])
)
)
var total_appr =
CALCULATE(
SUM('Table'[Appropriation]),
FILTER(
ALL('Table'),
'Table'[year] = MAX('Table'[year])
)
)
RETURN IF(HASONEVALUE('Table'[Reporting Period]), total_ex / (total_appr * [value]), BLANK())
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- vtechBI2 years ago
Helper I
Dear Sir,
Thanks for the feedback.
I would like the table filter to included this periods ranges, not the Maximum period.
Sum of Expenditure ("2023 Q1", "2023 Q2") and Budget Period= A23
DIVIDED BY
0.5 x Sum of Appropriation ("2023 Q1", "2023 Q2", "2023 Q3", "2023 Q4") and Budget Period= A23
KPI =var total_ex =CALCULATE(SUM('Table'[Expenditure]),FILTER(ALL('Table'),'Table'[Reporting Period] = MAX('Table'[Reporting Period])))var total_appr =CALCULATE(SUM('Table'[Appropriation]),FILTER(ALL('Table'),'Table'[year] = MAX('Table'[year])))RETURN IF(HASONEVALUE('Table'[Reporting Period]), total_ex / (total_appr * [value]), BLANK())