Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am using the calendar that the source data uses, which is:
year, quarter, month_no_id, week_no_id, calendar_date (datetime) and have added date_id, week, month_no, monthName and day .
For a given selection of year, month_no, week_no and day:
=sum({$< day = {$(#=Only(day ))},week_no_id=, month_no_id=>} sales ) works correctly
=Sum({<Year=, Month=, Quarter=, Week_no=, day=, date_id={'>=$(=Num(MonthsStart(Max(date_id))))<=$(=Max(date_id))'}>} sales)
also works correctly to give the Month to date.
but
=Sum({<Year=, Month=, Quarter=, Week_no=, day=, date_id={">=$(=Num(WeekStart(Max(date_id))))<=$(=Max(date_id))"}>} sales)
does not give the correct figure.
Also, changing the "Year=" to "year=" gives a different result.
What am I missing here?
Which Month are you talking about?
=Sum({<Year=, Month=, Quarter=, Week_no=, day=, date_id={'>=$(=Num(MonthsStart(Max(date_id))))<=$(=Max(date_id))'}>} sales)
I am talking about the first one - the one in Red in your post.
The keyword Week is not available to use.
Do you have a field called Week in your dashboard? May be you have Month field, but no Week field which is why you don't see week....although you did add Week_No in your expression..... Set analysis works with fields (mostly) from your back end
Yes, that is it. Thanks again Sunny.
Thanks again Sunny.
This is what ended up working for the Week To Date (which won't display at all if a Week is not selected and won't display the WTD if a day is not selected):
If(ISNULL(GetFieldSelections(day)),sum({$<week_no= {$(#=Only(week_no))}, month_no_id=>} no_of_units) ,If(ISNULL(GetFieldSelections(week_no)), 0, Sum({<Month_no=, day=, month_no_id, date_id={">=$(=Num(WeekStart(Max(date_id))))<=$(=Max(date_id))"}>} no_of_units)))
and for the MTD, which won't display unless a month is selected and won't display the MTD unless a day is selected:
If(ISNULL(GetFieldSelections(day)),
If(ISNULL(GetFieldSelections(week_no)), sum({$<month_no = {$(#=Only(month_no))}, week_no=>} no_of_units),Sum({<week_no=, day=, date_id={">=$(=Num(MonthStart(Max(date_id))))<=$(=Max(date_id))"}>} no_of_units)),
Sum({<week_no=, day=, date_id={">=$(=Num(MonthStart(Max(date_id))))<=$(=Max(date_id))"}>} no_of_units))