Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
kaushi2020
Creator II
Creator II

How to show data for top 3 categories for a week

Hi All, 

I have a dataset where I am calculating top 3 Category and count for these for 7 days.

Once i have labels for top 3 categories, I want to see count of these categories on a  line chart as 3 lines.

 

Here while plotting this on line chart I found that when adding a dimension day the category is getting changed. 

Dimension: Date

Line: Category

Measure: 

Sum({$<Year=, Month=, Day=,category={'Voice'},
Date={">=$(=date((max(Date)-6)))<=$(=date(max(Date)))"}>}
occurrences)

 

kaushi2020_0-1701951318423.png

If you see here in the above table, I have top 3 categories based on the count from the measure cals.

But when i am adding the line where i have added a dimension as Date this is calculating top 3 for each day for Top 3.

Expectation: 

Show data/count for only those 3 categories from the top 3 categories only.

 

please suggest. 

 

1 Solution

Accepted Solutions
vincent_ardiet_
Specialist
Specialist

You can try with this expression (instead of using the top 3 mechanism):
Sum({$<Year=, Month=, Day=,category={'Voice'},
Date={">=$(=date((max(Date)-6)))<=$(=date(max(Date)))"},
ActivityCode={[=Rank(Sum({$<Year=, Month=, Day=,category={'Voice'},
Date={">=$(=date((max(Date)-6)))<=$(=date(max(Date)))"}>} occurrences))<=3]}
>}

occurrences)

View solution in original post

2 Replies
vincent_ardiet_
Specialist
Specialist

You can try with this expression (instead of using the top 3 mechanism):
Sum({$<Year=, Month=, Day=,category={'Voice'},
Date={">=$(=date((max(Date)-6)))<=$(=date(max(Date)))"},
ActivityCode={[=Rank(Sum({$<Year=, Month=, Day=,category={'Voice'},
Date={">=$(=date((max(Date)-6)))<=$(=date(max(Date)))"}>} occurrences))<=3]}
>}

occurrences)

kaushi2020
Creator II
Creator II
Author

@vincent_ardiet_ Thanks a lot for your reply. It worked perfectly for my scenario. 🙂