Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
ebest74
Contributor
Contributor

Getting an average from specific dimension results

Hi All!  Hoping for some help here.

I am new to QlikSense and have a clinical healthcare background not technical so I apologize if I use the wrong language here.

I am creating a dashboard to compare hospital discharge times across various sites.  On one sheet I am trying to create a comparison that shows all six sites without the end user having to make the selections.  For the patient count I am using the expression in a KPI of (count({<Organization={'Hospital A'}>}Organization)) which gives me the results of just that facility.  For the average time I am using a KPI with the expression avg(if([DC TAT]<5760,([DC TAT]))) which gives me the average but for all the facilities involved.

Essentially I trying to jam those two expressions together so I can have a KPI that shows the Avg DC TAT only when it equals Hospital A, Hospital B, etc..

I have tried various expressions and have googled like crazy but cannot seem to figure it out.  My guess is I need to use Aggr function but I cannot seem to get an expression that works correctly.

Any thoughts would be greatly appreciated! 

5 Replies
Taoufiq_Zarra

can you share a sample data and the expected output ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
ebest74
Contributor
Contributor
Author

I'm using KPIs to display the data now.  One KPI for the total count and one for the average time.  As it stands now the user would have to select the various facilities to compare.  I'm looking for an expression that would essentially only show the average of a specific site.2020-03-19_9-52-31.jpg

 

Below is a cut out of my raw data.  So looking for an expression that shows DC TAT Average only when the Organization equals either Hospital A or Hospital B.

In my brain this would be something like the below which of course doesn't work...just displaying what my mind thinks it should be....

=Avg(if([DC TAT TIME]<5760,([DC TAT TIME])))when(count({<Organization={'Hospital A'}>}Organization))

 

OrganizationDischarge Date & TimeDC TAT
Hospital A03/03/2020 08:30:00 PM438
Hospital A03/04/2020 11:06:27 AM39
Hospital A03/13/2020 03:13:46 PM139
Hospital A03/05/2020 03:15:00 PM53
Hospital A03/11/2020 11:40:07 AM72
Hospital B03/07/2020 01:13:00 PM149
Hospital B03/08/2020 11:46:00 AM75
Hospital B03/08/2020 02:43:09 PM234
Hospital B03/09/2020 07:05:51 PM84
Hospital B03/10/2020 09:15:13 AM42
Hospital B03/11/2020 07:40:00 PM393
Hospital B03/11/2020 06:41:00 PM283
Taoufiq_Zarra

can give you more information about the requested formula,
on the basis of the sent extract what is the value of the AVG and how you calculate it, to test it with my suggestion

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
ebest74
Contributor
Contributor
Author

I hope I'm answering your question correctly...but in the case of the small sample of data below I would have a KPI for Hospital A for total number of patients which would be 5 then a separate KPI that would show the average DC TAT for just Hospital A which would be 148.

So the expected results of the KPI formula would be to show avg DC TAT only when the Hospital is A, B, C, etc..

ebest74
Contributor
Contributor
Author

Wanted to reach out on this subject again...anyone smarter than me (casting a REALLY wide net) have any thoughts/ideas how I can write this expression??

Appreciate it!