Difference between two fields and aggregation

Hello,

I would like to calculate a simple difference between two fields (date type) but with an aggregation on another field

I was expecting a function like dateDiffOver, but at the moment I could not find it…

any suggestion on how to do this?

Hi @remba87

Thank you for your question.

Please check if the the documentation below can help

Regards,

Demola

Hi @demola,

I saw this, but it does not allow me to group by on field in the calculation…

this is an example of my data set:
image

I want the data diff grouped by the id as calculated field…

Hi @remba87 - What is your expected output? Please provide some more details around it.

Regards - Sanjeeb

@Sanjeeb2022

Yes, sure.

I expect
3 (coming from id 1)
14 (coming from id 2)
27 (coming from id 3)

Hi @remba87 - Thanks. You can use date diff function so that each row have the difference in days , when you will use the field in analysis on the group by Id, it will automatically give you the distinct value. You do not need any explicit aggregate function. Give a try and if it is not achievable, please let us know.

Regards - Sanjeeb

@Sanjeeb2022

I tried that and it works if I want to show it in a table but if I would like to show this field in a vertical bar chart,Let’s say I have this dataset.

image
I want to show in a barchart that data diff 3 has happened 2 times (one for id I and 1 for id 4), datadiff 14 has appened 1 time and data diff 27 has happened 1time…

If I just use data diff, I will not get what I want

Hi @remba87 - I am getting the correct result in Analysis… Can you ensure to put the data_1 and data_2 fields in group by column and also ensure the date format is correct. See the sample result below.

Regards - Sanjeeb

Hello,

yes that was working to me too…the problem was how to do the vertical bar visual…but now I found it…

I had just to use the data diff parameter (dateDiff({fdata 1},{data 2}) as x axis and put nothing in the value…

for me this is weired but good to know now :slight_smile:

1 Like

Thanks @remba87 . Glad it is resolved now. Please mark your suggestion as solution so that it can help other community members down the line.

Have a great week ahead.

Regards - Sanjeeb

1 Like