Hi. How can we help?

Change days since sold to last date sold

On a report, you can change the product sale details from Days Since Sold to Last Day Sold. This calculation can be prepared from an Inventory report, for example, a Dusty Inventory report, because Days Since Sold is an included measure.

From the collection of Date Functions, you can use the Add_Days function to count backward from the current day. There are two arguments to Add_Date: 

  • The first argument is the number difference.
  • The second argument is the date that you want to adjust. It will be similar to: (difference, start date). The function should be : (negative days since sold, today). 

To change Days since sold to Last day sold:

  1. Start a new Table Calculation.
  2. In the calculator, search for and add the add_days function.
    Retail-R-analytics-add-days-function.png
  3. In the brackets, insert a subtraction symbol and the last day sale function.
    Retail-R-analytics-add-days-source-date.png
  4. Insert now() as the source date. This will add a column with the timestamps of the days since last sold, with the time frame being the current time. 
    Retail-R-now()-source-date.png
  5. Next, change now to the date function.
    Retail-R-analytics-date-function.png
  6. Since the date function requires three arguments (year, month, day), prepare the function by adding three sets of brackets within the existing bracket.
    Retail-R-analytics-date-function-three-arguments-setup.png
  7. Next, to find the year, month, and day from now, insert one of the functions extract_year, extract_month, and extract_day within each set of brackets.
    Retail-R-analytics-date-function-three-arguments.png
  8. Insert the now() function into all three empty brackets. The final calculation should be:
    add_days(-${cl_item_facts.days_since_sold},date((extract_years(now())),(extract_months(now())),(extract_days(now()))))
    Retail-R-analytics-last-date-sold-final-calculation.png
  9. Save the calculation.

The table will include a new column with the results of the calculation as year, month, day, for each row.

Retail-R-analytics-last-date-sold-finalized-table.png
 

Was this article helpful?

0 out of 0 found this helpful