Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
I need to design a bar graph with Dimension (B_Mode)and with a expression which accumulate last three months avg(Count_Br ) excluding the selected month
For Example :i have max data till 2019 Oct.
if no month and year is selected it has to then take the avg of past three months(Sep,Avg,Jul)
if any month is selected (2019,Feb) then it should take avg of the past three months(2019Jan,2018Dec,2018,Nov)..
Chart:Bar Chart
Dimension: B_Mode
Expression: Avg({ ? }Count_Br)
Thank
Please find the attached sample data...
try below script
avg({<Year,M_Month, Date = {">=$(=monthstart(addmonths(max(Date),-3)))<=$(=monthend(addmonths(max(Date),-1)))"}>}Count_Br)
this should work
=alt(avg({<Year,M_Month, Date = {">=$(=monthstart(addmonths(max(Date),-3)))<=$(=monthend(addmonths(max(Date),-1)))"}>}
aggr(sum({<Year,M_Month, Date = {">=$(=monthstart(addmonths(max(Date),-3)))<=$(=monthend(addmonths(max(Date),-1)))"}>}Count_Br),
Year, M_Month)
),0)
"if any month is selected (2019,Feb) then it should take avg of the past three months(2019Jan,2018Dec,2018,Nov"
not clear ?
Hi ,
I mean if a year 2019 and month Feb is selected from year and month filters.
What is the AVG of past three months is:
AVG of past three months are values of
2019 Jan
2018 Dec
2018 Nov
should bypass the year selection
Perhaps this?
Avg({<Month={">=$(=AddYears(Max({<Year>}Month),-3))<=$(=Max({<Year>}Month))"}>} Sales)
Hi Anil,
I have tried your expression, but it not working ..something is missing in below bold set analysis
Avg({<Month={">=$(=AddYears(Max({<Year>}Month),-3))<=$(=Max({<Year>}Month))"}>} Sales)
Hello All,
Any suggestion for the above requirement ...
Thanks
My bad, Should be
Avg({<Month={">=$(=AddMonthsAddYears(Max({<Year>}Month),-3))<=$(=Max({<Year>}Month))"}>} Sales)
I have done a change still its not working
Avg({<Month={">=$(=Date(AddMonths(Max({<Year>}Month),-3),'MMM')<=$(=Max({<Year>}Month))"}>}sales)
@Anil_Babu_Samineni's function works very well
=Avg({<Month={">=$(=AddMonths(Max({<Year>}Month),-3))<=$(=Max({<Year>}Month))"}>} Sales)
why are you adding Date() ?
if not can you share your Qlik file ?
Hi,
Sorry to say but i am not allowed to share it,but i have attached a sample data file.