Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
reporting_neu
Creator III
Creator III

Count Range by Dimenson

Hello,

I would like to count the number of days per year and dimension. However, I can't cope.

I have:

MDNr ANNr Datefield Yearfield Day
1 878 01.01.2024 2024 1
1 878 02.01.2024 2024 1
1 878 03.01.2024 2024 1
1 878 10.01.2024 2024 1
1 878 11.01.2024 2024 1
1 878 28.05.2024 2024 1
1 900 29.12.2023 2023 1
1 900 30.12.2023 2023 1
1 900 01.01.2024 2024 1
1 900 02.01.2024 2024 1
1 900 03.01.2024 2024 1
1 900 04.01.2024 2024 1
1 900 28.01.2024 2024 1

Comment: Day is everytime "1"

I need the following result:

MDNr ANNr Datefield Yearfield Countfield
1 878 01.01.2024 2024 1
1 878 02.01.2024 2024 2
1 878 03.01.2024 2024 3
1 878 10.01.2024 2024 4
1 878 11.01.2024 2024 5
1 878 28.05.2024 2024 6
1 900 29.12.2023 2023 1
1 900 30.12.2023 2023 2
1 900 01.01.2024 2024 1
1 900 02.01.2024 2024 2
1 900 03.01.2024 2024 3
1 900 04.01.2024 2024 4
1 900 28.01.2024 2024 5

 

My load script:

NoConcatenate
TMP2:
Load
MDNr
,Yearfield
,ANNr
,Datefield
,if(previous(MDNr) = MDNr and previous(Yearfield) = Yearfield and previous(ANNr) = ANNr, rangesum(peek('Countfield'), Day), Day) as Countfield
Resident TMP1
Order by MDNr, ANNr, Yearfield, Datefield ASC;

Who can help me, please?

Labels (3)
12 Replies
reporting_neu
Creator III
Creator III
Author

Yes, I did.

By ANNr or Yearfield
2024-08-12 12_53_39-.png
No separation between years

if(ANNr <> Previous(ANNr) or Yearfield <> Previous(Yearfield), 1, RangeSum(Peek('Count'),1)) as Count
...
Order by ANNr, Yearfield, Datefield;

 

By only Yearfield
2024-08-12 13_27_50-.png


2024-08-12 13_30_55-.png
No separation between years and ANNR

if(Yearfield <> Previous(Yearfield), 1, RangeSum(Peek('Count'),1)) as Count
...
Order by ANNr, Yearfield, Datefield;

 

Kushal_Chawda
MVP
MVP

@reporting_neu  I don't see year field in your snapshot data. If you don't have that, you need to create it

reporting_neu
Creator III
Creator III
Author

Good point! I had the “Yearfield” field. However, there was a wrong field behind it and no year. I corrected that and now it works as it should 😃

Thank you so much! 👍