Percent of total for bar graph

Hi All,
Despite a lot of googling and looking through this forum, I can’t work the following out:
I have a bar graph which displays the number of patients admitted to the stroke unit per month (pic 1).

I need this to actually display the percentage of admissions to the hospital which end up being admitted to the stroke unit.

I know the calculated field I created is incorrect as it’s now displaying as pic 2.

Can anyone help me with what the script should actually be?

For reference, this is my admissions per month graph:

Thank you.

@jotg - It seems you need to create a calculated field by dividing the 438Treatedinastrokeunit field by the admission field. Something like below and format that as percent

sum(treatedinstrokeunit) / sum(admitted)

Then project that field against the Date Dimension in Line chart. Hope this helps!

@sagmukhe

Thanks.

After some trial and error, rather than sum, it was more appropriate for me to use count.

And if anyone else has a similar query to mine, this is the script I used:

count({438Treatedinastrokeunit})/count(patientrecordid)

My chart now looks like this (which is exactly how I needed it):

.

Thanks again for your help.

Hi @sagmukhe On reviewing what I did here, I realise this is still not correct. I actually need to know the percentage of patients who presented with a stroke that were then admitted to the stroke unit.

The stroke unit field has the following response options- Yes (1), No (2), Unknown (9), and some will be blank. I only want to count those where the response is 1 and then get a percentage of those compared to the total.

I tried this script (not that each patient record has an id number, and that’s why I’m using a count of those as my denominator):

image
But I’m getting an error.

I also tried a couple of different scripts using the %oftotal function:

image

image

Neither are correct.

Any assistance would be appreciated.
Thank you.

@jotg - Did you try the countIf function to determine the count of stroke unit field only having the value 1?

1 Like

@sagmukhe What would script be if I was using the countIf function?

@sagmukhe I tried this script, and there is still an error:

image

What am I missing here?

Thanks again for all of your assistance to date.

@jotg - The syntax of countIf seems to be wrong in the example screenshot that you shared. Please go through the below link and that should perhaps help you to see the correct implementation.

It should be something like below:

countIf(patuentrecordid, {438Treatedinastrokeunit} = ‘1’)/count(patientrecordid)

Let me know if this helps! Thank you!

1 Like

@sagmukhe I don’t really understand the rationale behind that script but yes, that worked. Once again, thank you very much for your help.

1 Like