Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
zakpullen
Creator
Creator

Adding standard deviation to a 12 month line chart

Hi,

I have a 12 month line chart with this expression:

SUM({<MonthYear={">=$(=Date(MonthStart(Max(MonthYear),-11),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear)),'MMM-YY'))"}>}[PDR %])

The dimension is MonthYear (essentially the last day of the month)

I want to add standard deviation as a reference line. This needs to adjust with the chart if a different MonthYear is selected, i.e. the standard deviation should be based on the 12 data points in the chart.

Many thanks

Labels (1)
1 Solution

Accepted Solutions
alejandroquinones
Partner - Creator
Partner - Creator

Hey @zakpullen ,

 

You may try the following expression with the inner set expression

Stdev({<MonthYear={">=$(=Date(MonthStart(Max(MonthYear),-11),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear)),'MMM-YY'))"}>} 
  TOTAL Aggr(
    Sum({<MonthYear={">=$(=Date(MonthStart(Max(MonthYear),-11),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear)),'MMM-YY'))"}>} [PDR %]), 
    MonthYear
  )
)

 

Or with the outer set expression

{<MonthYear={">=$(=Date(MonthStart(Max(MonthYear),-11),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear)),'MMM-YY'))"}>}  Stdev(TOTAL Aggr(Sum([PDR %]), MonthYear))

 

Greetings,

Alex

View solution in original post

3 Replies
alejandroquinones
Partner - Creator
Partner - Creator

Hey @zakpullen ,

 

You may try the following expression with the inner set expression

Stdev({<MonthYear={">=$(=Date(MonthStart(Max(MonthYear),-11),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear)),'MMM-YY'))"}>} 
  TOTAL Aggr(
    Sum({<MonthYear={">=$(=Date(MonthStart(Max(MonthYear),-11),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear)),'MMM-YY'))"}>} [PDR %]), 
    MonthYear
  )
)

 

Or with the outer set expression

{<MonthYear={">=$(=Date(MonthStart(Max(MonthYear),-11),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear)),'MMM-YY'))"}>}  Stdev(TOTAL Aggr(Sum([PDR %]), MonthYear))

 

Greetings,

Alex

zakpullen
Creator
Creator
Author

Thank you so much. They both work.

alejandroquinones
Partner - Creator
Partner - Creator

Glad it worked!