Excellent, with that data, I ... well, we'll see if this is *right* or not, but at least it's gonna be way closer. I converted your data into a CSV file and uploaded to my system so I have a thing I can use with `| inputlookup` (I'll paste all code later, after the screenshots so you can copy/paste it if needed). I had to fiddle a little with the date formats (not worth my effort to figure why), but then I got the new fields created. In addition, I assigned the field `_time` to dataout, perhaps that should be set to datakpi instead. Either way, that's left as an exercise for the reader. Also my fields are differently named, I'm sure you'll figure that part out and correct as you want. 🙂 If you are color blind, I can do something different here but hopefully it'll come across OK. And, now that we have told Splunk what field to use as _time, things like timechart will work. And in timechart, you can actually do some pretty complex conditional expressions if you want. Much of this can also be done by replacing the `timechart span=1mon` command with the pair of commands `bin span=1mon _time` and a big stats like the timechart, split by _time. Stats is more versatile, but I think either works fine in this case. Stats may also be *slightly* better performing if you are in a large Splunk distributed system, but I doubt the difference is large. And as mentioned, if you want to move that complexity out of the timechart/stats command and into its own eval, it would look like this: You can do a similar thing with the timechart one too. As promised, the actual code, stats one with separate evals first because that's what's on my screen right now and I'm lazy. KEEP IN MIND that you'll have to swap out my `| inputlookup lookup_KPI.csv` command for your own search, and fix up those dates again back to the right way. Also change field names in the "AS blah" sections. | inputlookup lookup_KPI.csv
| eval dataout = strptime(DATA_OUT,"%d/%m/%Y")
| eval datakpi = strptime(DATA_KPI,"%d/%m/%Y")
| eval diff_day = round((datakpi - dataout)/86400,0)
| eval _time = dataout
| eval sum_for_direct_attive = if(CANALE=="direct" AND TIPO=="attive", 1, 0)
| eval sum_for_diff_day_over_45 = if(diff_day <= 45, 1, 0)
| bin span=1mon _time
| stats sum(sum_for_direct_attive) AS direct_attive sum(sum_for_diff_day_over_45) AS diff_day_over_45 BY _time
| eval perc = round((direct_attive/diff_day_over_45)*100,2) Stats one with sum(eval...) syntax: | inputlookup lookup_KPI.csv
| eval dataout = strptime(DATA_OUT,"%d/%m/%Y")
| eval datakpi = strptime(DATA_KPI,"%d/%m/%Y")
| eval diff_day = round((datakpi - dataout)/86400,0)
| eval _time = dataout
| bin span=1mon _time
| stats sum(eval(if(CANALE=="direct" AND TIPO=="attive", 1, 0))) AS direct_attive sum(eval(if(diff_day <= 45, 1, 0))) AS diff_day_over_45 BY _time
| eval perc = round((direct_attive/diff_day_over_45)*100,2) And the timechart one, just for good measure. | inputlookup lookup_KPI.csv
| eval dataout = strptime(DATA_OUT,"%d/%m/%Y")
| eval datakpi = strptime(DATA_KPI,"%d/%m/%Y")
| eval diff_day = round((datakpi - dataout)/86400,0)
| eval _time = dataout
| timechart span=1mon sum(eval(if(CANALE=="direct" AND TIPO=="attive", 1, 0))) AS direct_attive sum(eval(if(diff_day <= 45, 1, 0))) AS diff_day_over_45
| eval perc = round((direct_attive/diff_day_over_45)*100,2) I hope this gets you the answers you need! Happy Splunking, Rich
... View more