Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis Question

Hello everyone,

I have a table like this:

DateTimeStatusTap_Id
01/01/2012 14:00open1
01/01/2012 15:00close1
02/01/2012 14:00open1
02/01/2012 4:30close1
02/01/2012 4:45open1
03/01/2012 20:00close1
03/01/2012 20:00open1

I want to build a simple chart that will present for each day and tap the last status  - open or close (the biggest datetime for each day)

Thanks in advance.

16 Replies
Not applicable
Author

Thank you all for helping me.

I didnt give up.... i will find a way to solve this with set analysis....

azimabadi
Creator III
Creator III

Pleas write the answer here when you find a way to do this with SA. I'm really interested to see that is this posible with use of SA or not.

Best Regards

Peyman

Not applicable
Author

Hi, I've come to the conclusion that you cant achieve this with set analysis, the reason is below:

The reason is, that when you define a set in set analysis it defines the set as if you were making selections in all the data. It doesn''t take into account the dimension or divide up the data by dimension.

So if you include an expression in the set analysis, this is performed first over the full set of data before being applied to each element in the dimension.

so in the example above if you were to reference $(=max([chosen_field]) in the set analysis this would work out the max(chosen_field) for all the data before applying that static max to the dimension. So there is no immediately easy way to use set analysis differently dependant on what was in the dimension.

Hope this helps clarify things!

Erica

sebastiandperei
Specialist
Specialist

Dear Matan, I like the people that never gives up!!

In first place, with a table with "date" as dimention (if you don't have the "date" field, you could create with a calculated dimention like =Left(date(DateTime),10)), the expression that gives to you the last state is:

=FirstSortedValue(State, -DateTime)

But, for make this with SA, you need to tell to the expression witch values are available. These available values will be only the max for each day. The expression would be:

Only({<DateTime={$(vMaxTime)}>}Status)

Because of sintaxis of SA, you cant use search query inside another search query, and to make that you need to make a variable. In this case, it would be:

='"*'&Concat(left(Timestamp(Aggr(max(DateTime),date)),16),'","*')&'"'

This variable creates a search string, with the values of the max for each day. From inside to outside, Aggr(Max(DateTime), date) gives you the max values aggregated by date. Then, with TimeStamp, you transform it to a timestamp string. I used Left to pick out the seconds, because if you use the [Format] parameter of TimeStamp, you could give round problems, and have a difference of minutes, creating invalid timestamps. Note that if you have hours less than 10, you should use left(...., 15). I recomend that you format these field to HH:MM:SS, or HH:MM and don't use Left.

Then, the Concat creates the complete string with all the max values.

Im agree with you, IT IS POSSIBLE!!

sebastiandperei
Specialist
Specialist

matan...  I taked time in response your question, and also explain you the solution, and you not even mark as answered?

Not applicable
Author

Thanks a lot !!!

Somehow i knew it can be done.

Sorry for not comment earlier- i've been on vacation.

Did you know if this solution is easier to calculate then the firstsortedvalue formula ?

Thanks again for your effort

sebastiandperei
Specialist
Specialist

Its Ok Matan!! Did you went to any vacation place?

The solution with firstsortedvalue is most simply, but i don't know if it's faster to calculate...

You can try both and comment to us!