Skip to main content

data exampleThe logic is as follows:

  • if a category repeats (like C1), then:
  • for each category, calculate the date difference (DATEDIFF) between "closed at" date of a row with "closed" status and the "opened at" date of the rows with an "open" status.

 

The objective is to have an extra column to the right, with these values:

Difference (in days)

18 (DATEDIFF(dd,17.09.2021,30.08.2021)

16 (DATEDIFF(dd,15.09.2021,30.08.2021)

N/A (because its status is closed)

N/A (because the category doesn't repeat)

N/A (because the category doesn't repeat)

 

Suggestions?

Hi @luis.magal,

 

Not sure if the code below will work, since you will use a pull-up function only partially in your formula, but it is worth a try:

 

CASE

WHEN "<TABLE_NAME>"."status" = 'open'

THEN DATEDIFF(DD,

"<TABLE_NAME>"."opened at",

PU_LAST(DOMAIN("<TABLE_NAME>"."category") , "<TABLE_NAME>"."closed at" , "<TABLE_NAME>"."status" = closed)

)

ELSE NULL

END

 

These are the steps you take:

  1. The code checks if the status is open for that row
  2. If so, you will do a datediff, as you already suggested. First you take the 'opened at' date, secondly, you create a Pull-up fuction, that looks for all the categories in the 'category' column. for each category, it will take the last value of the 'closed at' column, where 'status' is 'closed'.
  3. If the status is not open, it will return null

Hi @luis.magal,

 

Not sure if the code below will work, since you will use a pull-up function only partially in your formula, but it is worth a try:

 

CASE

WHEN "<TABLE_NAME>"."status" = 'open'

THEN DATEDIFF(DD,

"<TABLE_NAME>"."opened at",

PU_LAST(DOMAIN("<TABLE_NAME>"."category") , "<TABLE_NAME>"."closed at" , "<TABLE_NAME>"."status" = closed)

)

ELSE NULL

END

 

These are the steps you take:

  1. The code checks if the status is open for that row
  2. If so, you will do a datediff, as you already suggested. First you take the 'opened at' date, secondly, you create a Pull-up fuction, that looks for all the categories in the 'category' column. for each category, it will take the last value of the 'closed at' column, where 'status' is 'closed'.
  3. If the status is not open, it will return null

It worked! Thank you!


Reply