3 Replies Latest reply on Nov 21, 2018 9:03 AM by Divya Chhabra

# How can I group certain values and create a graph of their trends over time?

Hi,

I have blood sugar levels that I would like to group as "below 5", "5.1-7.9" or "above 8" and then create a line graph over time that shows the those levels changing over time.

I can't share the workbook because it contain patient information, but here are my columns:

Patient ID

Patient Name

Lab Date

Lab Value

So, I would like to see a lab value of 4.6 and group it as "below 5," then see a lab value of 7.3 and group it as "5.1-7.9" etc and use Lab Date to plot these values per month as a percent of total lab values in that month.

I've tried to use sets with a condition of "Lab Value <=5.0" but it's counting all Lab Values as below 5.0, even if the value is above 5.0.

Any help is much appreciated!

Thanks,

Divya

• ###### 1. Re: How can I group certain values and create a graph of their trends over time?

You don't need to share patient data, but you can make some dummy data.

If you need people to respond faster for your forum requests, please always provide a data file and/or a packaged workbook with data. People who are helping here may not necessarily have the time to make data for you and then provide the solution.

• ###### 2. Re: How can I group certain values and create a graph of their trends over time?

Hi Divya,

Step 1 - calculated field

Trend over time

if [Lab Value] <5 then 'below 5'

elseif [Lab Value] >=5 and [Lab Value] <=7.9 then '5 to 8'

elseif [Lab Value] >7.9 then 'above 8'

You can then put this against a date axis and see trend over time

Step 2 - calculated field

Rename your values to 7.3

if [Trend over time] = '5 to 8' then 7.3

You can then integrate this with your other data to show 7.3 for the 5 to 8 range but I'm hopping over this output because it doesn't make sense to me why you would do this

Step 3 - data viz

Drag [Trend over time] onto x axis and select count as the aggregation. Create a Table Calculation for % of total and set the range to Table (down)

Drag [Lab Date] onto the y axis and set the aggregation to month

Group 'below 5' and 'above 8' so that they appear as the second percentage

HTH In your above example, the code should have read [Lab Value] <= 5, it looks like you had the equation mixed in with the fieldname which Tableau would have errored out on.

Peter

1 of 1 people found this helpful
• ###### 3. Re: How can I group certain values and create a graph of their trends over time?

This worked for me, thank you!