Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 |
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';
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.
not getting desired output
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;