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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anuhya_kotha
Contributor II
Contributor II

Looping in qlik sense

Hi all,

I have created an expression to count the number of workcenters which are having capacity for a week greater than the maxcapacity. Below is the expression i have used to calculate at the week level.

 =Sum({<[Year Period]=>}Aggr(if(Sum({<[Capacity Week]={'$(vMaxCapacityWeek)'},[Year Period]=,[Capacity Year]={'$(vMaxCapacityYear)'}>}[Start Quantity]) >
((Sum({<KPI_Filter={'Capacity'},
[Capacity %DateKey]={">=$(=vCapacityHistoryMinDateKey)<=$(=vCapacityHistoryMaxDateKey)"},
[Year Period]=>}[Start Quantity])
/
Count({<[Capacity %DateKey]={">=$(=vCapacityHistoryMinDateKey)<=$(=vCapacityHistoryMaxDateKey)"},[Year Period]=>} distinct [Capacity Year-Week]))*1.25),1,0),[Work Center]))

Now i want to repeat the same expression to calculate it for each week greater than or equal to maxweek in the current month.

Labels (1)
2 Replies
steeefan
Luminary
Luminary

I'd suggest to perform this calculation in the load script rather than in one or more heavy-weight expressions.

Anil_Babu_Samineni

@Anuhya_kotha perhaps this

 =Sum({<Month={"$(=Max({<Week={"$(=Max(Week))"}>}Month))"}, [Year Period]=>}Aggr(if(Sum({<Month={"$(=Max({<Week={"$(=Max(Week))"}>}Month))"}, [Capacity Week]={'$(vMaxCapacityWeek)'},[Year Period]=,[Capacity Year]={'$(vMaxCapacityYear)'}>}[Start Quantity]) >
((Sum({<Month={"$(=Max({<Week={"$(=Max(Week))"}>}Month))"}, KPI_Filter={'Capacity'},
[Capacity %DateKey]={">=$(=vCapacityHistoryMinDateKey)<=$(=vCapacityHistoryMaxDateKey)"},
[Year Period]=>}[Start Quantity])
/
Count({<Month={"$(=Max({<Week={"$(=Max(Week))"}>}Month))"}, [Capacity %DateKey]={">=$(=vCapacityHistoryMinDateKey)<=$(=vCapacityHistoryMaxDateKey)"},[Year Period]=>} distinct [Capacity Year-Week]))*1.25),1,0),[Work Center]))

Bold one is added now, and the pink is optional in some cases.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful