Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

eaphymaoweave
New Contributor II

Current Week + Complete Selection KPI

I have an expression which allows shows me the sum of sales for the current week. However, when I select other weeks of data the KPI always just shows the sum of sales for the latest week selected. Is it possible to write an expression show the sum of sales for everything in the selection, but at the same time when nothing is selected show the sum of sales for the current week? My current expression is below.

Sum({<YearWeek={$=max({<YearWeek={"=[Year/Week Start Date]<=$weekstart(now(),-1,0)"}>}num#(YearWeek))}>}[Sales Qty])

1 Solution

Accepted Solutions
MVP
MVP

Re: Current Week + Complete Selection KPI

May be this

If(Len(Trim(GetCurrentSelections())) = 0, Sum({<YearWeek={$=max({<YearWeek={"=[Year/Week Start Date]<=$weekstart(now(),-1,0)"}>}num#(YearWeek))}>}[Sales Qty]), Sum([Sales Qty]))

Basically, the above expression is saying that when no selections have been made in the dashboard, then show the result of this expression

Sum({<YearWeek={$=max({<YearWeek={"=[Year/Week Start Date]<=$weekstart(now(),-1,0)"}>}num#(YearWeek))}>}[Sales Qty])

But as soon as selections are made, display the result of this expression

Sum([Sales Qty])

2 Replies
MVP
MVP

Re: Current Week + Complete Selection KPI

May be this

If(Len(Trim(GetCurrentSelections())) = 0, Sum({<YearWeek={$=max({<YearWeek={"=[Year/Week Start Date]<=$weekstart(now(),-1,0)"}>}num#(YearWeek))}>}[Sales Qty]), Sum([Sales Qty]))

Basically, the above expression is saying that when no selections have been made in the dashboard, then show the result of this expression

Sum({<YearWeek={$=max({<YearWeek={"=[Year/Week Start Date]<=$weekstart(now(),-1,0)"}>}num#(YearWeek))}>}[Sales Qty])

But as soon as selections are made, display the result of this expression

Sum([Sales Qty])

eaphymaoweave
New Contributor II

Re: Current Week + Complete Selection KPI

Thank you! Works perfectly