Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
zinebben
Contributor
Contributor

IterNo

Hello , i am trying to calculate the RPD  and to do that i need to sum the days and group them by month , 

to do this i create a table with the code below : 

date([DATE START]+IterNo()-1) as Date ,
year([DATE START]+IterNo()-1) as Year ,

date(monthstart([DATE START]+IterNo()-1),'MMM') as Month

resident Table_1
while [DATE START]+IterNo()-1<=[DATE END];

 

then I sum distinct DATE and group it by month and year, but i don't get the right  number of days 

here is a sample of results i get (column DAYS) and in column DURATION I've calculated : interval(DATE END - DATE START) wich is the right number of days that i need 

 

zinebben_0-1641221750331.png

 

any suggestions please ? 

 

4 Replies
Or
MVP
MVP

Your code is fine - your comparison isn't valid.

There are 28 days in the range starting with April 21st and ending with May 18th, inclusive (including parts of the 21st and parts of the 18th given the timestamp). 

However, subtracting one from the other will result in 27.

Or_0-1641222228561.png

 

 

zinebben
Contributor
Contributor
Author

In my case it's  the 27 days wich is correct because i don't want to calculate days according to Dates like it does : 

06/08/2021 10:29 =Day1

07/08/2021 10:29 = Day2 ...  ==> so i have 2 Days 

what i need is : from 06/08/2021 10:29 to 07/08/2021 10:29 = one Day  

in oder way after each 24 hours it calculate a day 

 

Or
MVP
MVP

If you're counting distinct(date), you'll get 28, as there are 28 distinct dates...

You can look at using DayName() - https://help.qlik.com/en-US/qlikview/May2021/Subsystems/Client/Content/QV_QlikView/Scripting/DateAnd... - for an offset to when the day starts, but since your day doesn't seem to start and end at a consistent time I'm not sure if that'll work here.

zinebben
Contributor
Contributor
Author

Thank you so mucjh for u're help I'll try  using the DayName and I'll let you know