Forum Discussion
Last Order Date and Age
Hi all,
I have a table of data that runs for each day from 2022 to 2024. Within this table, there could be multiple lines for Company Names, which each have a date attached. I can create a table that shows the company name and the date and select from the date to show the latest one. This works fine.
I then want to calculate the number of days from today based on that latest date, which I did as a measure, but it doesn't work, it either fails the graphic or re-apples all dates with the number of days alongside.
Ultimately I want the table to show only the last time someone ordered, then to show how many days this was, so that I can filter out anyone who has ordered in the last 6 months, leaving only comanies that have not ordered.
Is this possible and if so how?
The measure I created is:
Create a Measure to Get the Latest Order Date:
Latest Order Date = MAX('Margin Reports'[DATE])Calculate Days Since the Latest Order:
Days Since Last Order = DATEDIFF([Latest Order Date], TODAY(), DAY)Filter the Data for the Last 6 Months:
Orders Older Than 6 Months = IF([Days Since Last Order] > 180, 1, 0)Add Filters to the Table Visual:
- Place
Company Nameand[Latest Order Date]in the table visual. - Add
[Days Since Last Order]as a column to display the calculated days. - Use the
[Orders Older Than 6 Months]measure in the visual-level filter and set it to1to display only companies that haven’t ordered in the last 6 months.
- Place
3 Replies
- johnt75
Super User
Create 2 measures
Latest Order = MAX ( 'Margin Reports'[Date] ) Days since last order = DATEDIFF ( [Latest Order], TODAY (), DAY ) - mh2587
Super User
Create a Measure to Get the Latest Order Date:
Latest Order Date = MAX('Margin Reports'[DATE])Calculate Days Since the Latest Order:
Days Since Last Order = DATEDIFF([Latest Order Date], TODAY(), DAY)Filter the Data for the Last 6 Months:
Orders Older Than 6 Months = IF([Days Since Last Order] > 180, 1, 0)Add Filters to the Table Visual:
- Place
Company Nameand[Latest Order Date]in the table visual. - Add
[Days Since Last Order]as a column to display the calculated days. - Use the
[Orders Older Than 6 Months]measure in the visual-level filter and set it to1to display only companies that haven’t ordered in the last 6 months.
- Rich_Wyeth
Helper I
Thank you! I hadn't done quite enough Measures. This works a treat.
- Place