Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Doubts about expression/days

Hi everybody: I have a little question, i dont know what function or what to do in this case.

I have to calculate a quantity. I have a lapse of time this is a difference between when something is ordered and delivered. This is final date - initial date. For example 1 day or 5 days or 20. In the graphic i have to divide the quantity in the numbers of the diference . I dont know how to do this with the number of days.

1 - 15, 15-30, etc

Sory for my poor english, i´ll put the needed graphic.

In the dimension i´ve put =DAY(DATE((FechaFin - Fecha), 'YY/MM/DD')) . I see the dates, but i´d like to group them.

1 Solution

Accepted Solutions
JonnyPoole
Employee
Employee

Hi Jeremias - the function is dynamic. The 60+ bracket will automatically show as 60-75.  If you have values over 75 those will be in new classes.

To avoid that use an IF() like this

IF (  [Final Date] - [Start Date]  < 60,  Class( [Final Date] - [Start Date]  , 15) , '60+')

View solution in original post

15 Replies
JonnyPoole
Employee
Employee

Hi there,

i suggest using the class() function with your  Final Date - Initial Date to create the dimension.

Class (  [Final Date] - [Start Date] , 15) 

In this example 15 is the range for each bucket. This will create 'buckets' (like country, person etc...)  within which your expression will breakdown into.

Looking at the chart, your expression would be just something like this:   sum(Quantity)

maxgro
MVP
MVP

maybe class?

see attachment

MarcoWedel

=Class(FechaFin-Fecha, 15)

as dimension


Not applicable
Author

Thank you. Can i stop with the buckets in 60 for example?

I mean 0 - 15, 15-30, 30-45, 45-60 and 60+

Not applicable
Author

Thank you. Can i stop with the buckets in 60 for example?

I mean 0 - 15, 15-30, 30-45, 45-60 and 60+

JonnyPoole
Employee
Employee

Hi Jeremias - the function is dynamic. The 60+ bracket will automatically show as 60-75.  If you have values over 75 those will be in new classes.

To avoid that use an IF() like this

IF (  [Final Date] - [Start Date]  < 60,  Class( [Final Date] - [Start Date]  , 15) , '60+')

Not applicable
Author

Yeah, that works. Thank you.

Only a last question. How i change the 0 <= x < 15 to '0 to 15'

Cheers

JonnyPoole
Employee
Employee

sure you can purge the <>= signs and replace x with 'to' as follows;

IF (  [Final Date] - [Start Date]  < 60,  PurgeChar( Class( [Final Date] - [Start Date]  , 15,'to'),'>=<') , '60+')

Not applicable
Author

Thank you! Sory i have two more little questions.

I have negative values in the dates, i think that is an error in the data and that´s not my problem but i don´t wanna show this. How can i hide this values ? i have -15 - 0 . And i have values "-" i think they are nulls. How can i hide this values too?