I want to be able to limit a KPI, let's say turnover, to a specific time range which I chose by setting two variables: the lower bound and the upper bound.
I have created two tables, which I derive from the calendar-table.
month_start:
LOAD MonthYear as MonthStart
RESIDENT Calendar;
month_end:
LOAD MonthYear as MonthEnd
RESIDENT Calendar;
I create two filters, one for MonthStart and one for MonthEnd.
I set two variables. I know that GetFieldSelections()
returns a string so I convert it back to a date.
=date#(GetFieldSelections(MonthEnd), 'MM YYYY')
=date#(GetFieldSelections(MonthStart), 'MM YYYY')
Finally I use this expression to calculate the KPI:
SUM({$< MonthYear = {"<$(=vEndMonth)>=$(=vStartMonth)"}>} [turnover])
But it doesn't work. I get 0,00€.
What am I doing wrong? What am I missing?
EDIT:
Example Data:
LOAD *
Inline [
%date, country, turnover
01.01.2021, DE, 1000
10.01.2021, AT, 2000
23.01.2021, CH, 1500
12.02.2021, DE, 2300
23.02.2021, DE, 5000
02.02.2021, CH, 1200
09.03.2021, AT, 3000
10.03.2021, CH, 1000
31.03.2021, DE, 3400
01.04.2021, CH, 2200
]
There is a calendar attached to the %date
-field with the MonthYear
-field which is created as monthname(%date) as MonthYear
.
As result I want a Pivot Table with country
as row-dimension and MonthYear
as column. The measure is a master element with above formula.