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

Announcements
Join us at Qlik Connect 2026 in Orlando, April 13–15: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
carlcimino
Luminary
Luminary

Days/Weeks and Total

I have daily office visit data and a weekly census for that location.  How would I do the following?  I'm thinking I need to use a Total function but it doesn't seem to work.

Visits Syntax:

Count({<Year={$(yearselect)},Source-={'PSHR'},[Location Description]-={'Work From Home'},[Pay Status]={'Active'},Visit_Swipe={0}>} distinct [Employee ID])

Assigned Seats Measure Syntax:

Count( {<Year={$(yearselect)},Source={'PSHR'},[Location Description]-={'Work From Home'},[Pay Status]={'Active'}>} distinct [Employee ID])

Attached some sample data for reference.

carlcimino_0-1714590122774.png

 

Labels (2)
1 Solution

Accepted Solutions
igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

I believe Aggr can help you. Try something like this:

 

Sum(
Aggr(NoDistinct
Count({<Year={$(yearselect)},Source={'PSHR'},[Location Description]-={'Work From Home'},[Pay Status]={'Active'}>} distinct [Employee ID])
, [Local Description], Year, [Month Name], SwipeWeekStart
)

IPC Global: ipc-global.com
Check out my latest posts at datavoyagers.net

View solution in original post

7 Replies
igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

Can you add more context? What exactly is not working? What do you expect, what calculation? What are you getting instead?

IPC Global: ipc-global.com
Check out my latest posts at datavoyagers.net
carlcimino
Luminary
Luminary
Author

When I add total to the expression...

Count( total {<Year={$(yearselect)},Source={'PSHR'},[Location Description]-={'Work From Home'},[Pay Status]={'Active'}>} distinct [Employee ID])

The same number is in the expected in office column across all the weeks.  I expect that number to be the census for that week but it returns something else.
carlcimino_1-1714591631735.png

 

igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

I believe Aggr can help you. Try something like this:

 

Sum(
Aggr(NoDistinct
Count({<Year={$(yearselect)},Source={'PSHR'},[Location Description]-={'Work From Home'},[Pay Status]={'Active'}>} distinct [Employee ID])
, [Local Description], Year, [Month Name], SwipeWeekStart
)

IPC Global: ipc-global.com
Check out my latest posts at datavoyagers.net
carlcimino
Luminary
Luminary
Author

hi @igoralcantara thanks for your help that returns even more bizarre results.  i'll keep trying lmk if you think of anything else.

Sum( Aggr(NoDistinct Count({<Year={$(yearselect)},Source={'PSHR'},[Location Description]-={'Work From Home'},[Pay Status]={'Active'}>} distinct [Employee ID]) , [Location Description], Year, [Month Name], SwipeWeekStart ) )

 

carlcimino_0-1714593910222.png

 

igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

As an exercise, use my expression but replace the Sum for a Max just to see what we get.

IPC Global: ipc-global.com
Check out my latest posts at datavoyagers.net
carlcimino
Luminary
Luminary
Author

@igoralcantara This and your other suggestion eventually led to the solution.  I switched it to be a weekly view but the concept is the same.  Thanks so much for your help!

max(
Aggr(NoDistinct
Count({<WeekYear={'$(vMaxWeekSelect)'},Source={'PSHR'},[Location Description]-={'Work From Home'},[Pay Status]={'Active'}>} distinct [Employee ID])
, [Location Description], SwipeWeekStart
))

 

carlcimino_2-1714669038634.png

igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

Glad to hear!

IPC Global: ipc-global.com
Check out my latest posts at datavoyagers.net