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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
chagantiapps
Contributor
Contributor

display with in 5 days data

Hi Qlik Experts,

i have challenging task, hope you will provide the solution for following

i have a car repair data like below

example car no 121 has three repairs , but if the Repair description is same and if repair dates with in 5 days ,i have to show only auto Method record , can any one help on this in Qlikview or Qliksense

added input and desired output

input 

car no Repair decription Repair Date Method
121 back tyre change 21-02-2023 sm
131 regular checkup 12-05-2023 auto
131 regular checkup 16-05-2023 sm
121 Wheel change 23-01-2023 auto
121 Wheel change 28-01-2023 sm

 

 

desired output    
car no Repair decription Repair Date Method
121 back tyre change 21-02-2023 sm
131 regular checkup 12-05-2023 auto
121 Wheel change 23-01-2023 auto
Labels (4)
4 Replies
Chanty4u
MVP
MVP

Try this

Create a column in your script

If(Days(RepairDate - Previous(RepairDate)) <= 5 and Previous([Repair description]) = [Repair description], 'auto', Method) AS NewMethod

 

Use where repairdes='auto';

qlikeers
Creator II
Creator II

Hi!

I think AsOfTable could be useful to solve the problem:

https://community.qlik.com/t5/Design/The-As-Of-Table/ba-p/1466130

It would be necessary to prepare a table so that it could be used. That is, add +/- necessary days to one day.

 

chagantiapps
Contributor
Contributor
Author

not getting desired output

pravinboniface
Creator III
Creator III

How about this?  I know it's an extra pass over the data, but I feel it's easier to understand than getting the peek() Vs previous() nuances right and you do not have to worry about sort order.

RepairData:
Load * inline [
car no,Repair description,Repair Date,Method
121,back tyre change,2/21/2023,sm
131,regular checkup,5/12/2023,auto
131,regular checkup,5/16/2023,sm
121,Wheel change,1/23/2023,auto
121,Wheel change,1/28/2023,sm
];

Left Join
Load [car no],
	 [Repair description],
     [Repair Date]         as New_Repair_Date
Resident RepairData
where Method = 'auto';

FinalRepairData:
NoConcatenate
Load [car no],
	 [Repair description],
     [Repair Date],
     [Method]
Resident RepairData
where Method='auto'                              // auto records go in always
or Interval([Repair Date]-New_Repair_Date,'d')>5 // abs() may be needed
or IsNull(New_Repair_Date);                      // No matching auto record

Drop table RepairData;

exit Script;