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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Kaushik2020
Creator III
Creator III

How to calculate Average using Aggr to calculate based on Max (Day)

Deal All, 

I am using below expression to calculate my average

Avg(Aggr(count({$<Year=, Month=,Day=,
Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
distinct Txt_IssueID),Day))

 

The Date highlighted calculates 1st of month till max days when no Days selected in the Filter pane.

Eg: If Current_Date = 09-11-2023, then the date range will be --> 01-11-2023 till 09-11-2023 by default. 

 

While user is selecting 02-11-2023 from the Day filter pane in the UI, then this expression calculates Average for JUST 02. 

 

Expectation: It should calculate the average for 01 and 02.

Thanks in Advance.

3 Replies
Anil_Babu_Samineni

Your expression already seems OK.

Maybe  your expectation to remove Day in set analysis and see? otherwise, The users maybe selecting different fields and not from Date?

Avg(Aggr(count({$<Year=, Month=,Day=,
Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
distinct Txt_IssueID),Day))

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
Kaushik2020
Creator III
Creator III
Author

Thanks for your revert, when we select Day this expression is calculating based the day selection. 

I tried removing the Day, from the set expression but the date range is still the same. 

Avg(Aggr(count({$<Year=, Month=,
Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
distinct Txt_IssueID),Day))

Output is not changing. It is showing Average for only 9th. 

kaushi2020_1-1699865784495.png

 

 

vincent_ardiet_
Specialist
Specialist

Try:
Avg({$<Year=, Month=,Day=,Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
  Aggr({$<Year=, Month=,Day=,Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
    count(
distinct Txt_IssueID),Day))