How to obtain two most recent encounter dates? - max

I have used this expression in Cognos [Encounter Date]=maximum([Encounter Date] for [Patient Account Number]) to obtain the most recent visit. Does anyone know a command for two most recent visits?

Create a data item that ranks [Encounter Date] for [Patient Account Number]
Set the filter where [Rank] <= 2
Remember the filter should be AFTER aggregation (not the default before aggregation)

Related

Amazon Quicksight - Dynamic filter latest week by default

I think the question is fairly simple. I would like to have a dynamic filter on Quicksight. I have the column week which is a number (3, 4, 5 and 6) for example. The data is refreshed every week.
We want to show only the latest week by default (out of weeks 3, 4, 5 and 6, I want to filter by default on 6), but then the users can select if they want to see more weeks.
The week after, the default filter would be 7, and so on.
Is there a way to tell the filter to automatically filter by rule of MAX(week) or something like that?
It would be very helpful. I have other alternatives but they are not that great.
I would choose a date field that I understand that must exist in your data and then create a dynamic filter on that date field.
You create filters on date fields by selecting the filter conditions and date values that you want to use. There are three filter types for dates:
For your case, you will have to use
Relative – A series of date/time elements based on the current date. You can filter records based on the current date and your selected unit of measure (UOM). Date filter units include years, quarters, months, weeks, days, hours, and minutes.
Use the following procedure to create a relative filter for a date field.
On the toolbar at the left, choose Filter.
In the Filters pane that opens at left, choose the plus icon (+), and then choose a date field to filter on.
A new filter is added to the Filters pane.
In the Filters pane, choose the new filter to expand it.
For Filter type, choose Relative dates.
Choose a unit of time (week for your case).
Choose how you want the filter to relate to the time frame. For example, if you choose to report on weeks, your options are previous week, this week, week to date, last N weeks, and next N weeks.
If you choose Last n UOM, specify a number for your range—for example, last 2 weeks, or last 1 week.
Second solution.
Add Filter
Choose week
Type Top and Bottom Filter
Show Top write 1
By week ( use max aggregation)
Pasting an image from an analysis that I do the same thing for integer column year

Google DOC - Multiple FIlters combined

I'm a newbie when it comes to Google Doc Filters and I would appreciate some help.
I got a list with articles where I would like to filter by company (in this case SONY), but also filtering by lowest price combined with lowest shipping costs.
Example: the first filter I created, creates a list with SONY articles.
=(filter(A2:D12;A2:A12="SONY"))
Now I would like the filter to give out a single row, where the price and the shipping costs are the lowest, in this case, the product is:
SONY headphones with the price of 20 and shipping costs of 2,99
Im basically trying to combine the filters:
=(filter(A2:D12;A2:A12="SONY"))
=SMALL((C2:C12);2)
=SMALL((D2:D12);2)
in one single, long filter
Thank you
SEE SCREENSHOT HERE
Solution:
FILTER would not work in your case because you have a priority column to be filtered, in this case, column A before C and D.
You may use QUERY instead:
=QUERY(A2:D12,"select * where A='A' order by C+D limit 1")
This would select the entry with a specified value in column A (company), then order by the sum of C and D (price+shipping) in ascending order, and then output the first row, which is the minimum.
Sample Sheet:
References:
QUERY function
QUERY language

Daily unique count, weekly unique count in the same Timelion chart

I want to visualize the unique count for a field aggregated daily and weekly per day in the same sheet. But timelion aggregation affects the entire sheet instead of just a single chart.
The expression I am using to get the daily unique count is
.es(metric='cardinality:userId').bars().title('Unique users over time')
If I change the bucket range on the right to 1d, I get the correct chart. How do I create the weekly aggregation?
There is a possibility to specify the interval used for timelion expressions by specifying interval as 1d or respectively 1w in the es() function. For details, please see the docs here.
In your case this should work with the following expression:
.es(metric='cardinality:userId',interval=1w).bars().title('Unique users per week')
Be aware of the comment inside the docs, stating that this should not be used in favor of working with the interval picker. But probably this is a use case where it is okay to do it like this...

Kibana subtracting the values of 2 indices

I have 2 indices in kibana 4:
1st index is basing time from events (Date Created)
2nd Index is basing time from events (Date Closed)
Both are date values and I want to create a query which will return the total amount of docs Date Created (Today) - total amount of docs Date Closed (Today)
If this is not possible is it possible if i have both fields in one index?
Yes you need to have both the date values within the same index so that you can do the subtraction using a scripted field in Kibana. You could simply have your script as such:
doc.['date_created'].value - doc.['date_closed'].value
----------------^----------------------------------------^ Make sure to give your exact field names
And then you could use this scripted field as a Date Historgram to show the total count of the docs within the retrieved date range.
Hope this helps!

Sort version in tableau

I'm new in tableau, and I'm trying to build a report.
I have a field of versions,
e.g: 36.0.0.8667, 39.0.0.8267, 42.0.0.9639, 42.0.0.10249.
I need to find the two newest versions (meaning the highest value in the first part, from that group the highest value in the second part etc...) and make a comparison between the two of them and the average for all versions (between dates).
Does anyone have any idea how can I find the two newest versions?
Thanks!
tablelau for dashboard right?
you just need filter that can get 2 biggest valu from database
example like this.
the output will be 2 biggest value
select max(p.total),a.tot from product p,(select max(`total`) as tot from `product`) as a where total < (select max(`total`) from `product`);

Resources