cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KA95
Helper III
Helper III

Show value from the last 30-90 days from this current date?

Hi there, 

I was just wondering if there is a way I can create a measure that will show a total value for the last 30-90 days? 

So currently I have a table with two columns, an ID column and an date column. I have created a count measure that counts the ID's and it's called [Total Users] then I have a date column that's called [active_date].

How would I be able to get the [Total Users] from the last 30-90 days. I've tried the relative date filter tool but you can't set between conditions that's relative to todays date, so I'm hoping this can be done in a measure? 

1 ACCEPTED SOLUTION
Whitewater100
Super User
Super User

Hi:

Can you add date table and connect to our fact table on Date field? I'll paste new Date Table code below.. It should also be marked as a Date Table. Using the Dates[Date] field in your visuals:

Total Retail last 90 to 30 Days =
var lstdate = LASTDATE('SalesOrders'[Order_Date])
var lstdateless90 = lstdate -90
var lstdateless30 = lstdate -30
return
CALCULATE([Total Users], DATESBETWEEN(Dates[Date], lstdateless90, lstdateless30))
 
Date Table. MODELING> New Table

Dates = ADDCOLUMNS ( CALENDAR (FIRSTDATE(Sheet1[ Date]), TODAY()), "year", YEAR ( [Date] ), "MonthNumber", FORMAT ( [Date], "MM" ), "year-month", FORMAT ( [Date], "YYYY-MM" ), "month-year", FORMAT ( [Date], "MM-'YY" ) )

I would format the Dates[Date Field] to a Date like 

Whitewater100_0-1654737367140.png

I hope this helps..

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hello @Whitewater100 , can you please help?

I have created, below filter,

 

chinmayshah16_0-1673483250971.png

In the marks card I want to display today's date minus what ever the option I pick from the slicer,

So if today is 11 January, 2023 and user pick 'last 6 months' from the slicer then I would like to display, 

(11 July, 2022 - 11 January, 2023)

It should keep on changing based on what user pick from the slicer.

How can I do that? Please help!

 

 

 

Whitewater100
Super User
Super User

Hi:

Can you add date table and connect to our fact table on Date field? I'll paste new Date Table code below.. It should also be marked as a Date Table. Using the Dates[Date] field in your visuals:

Total Retail last 90 to 30 Days =
var lstdate = LASTDATE('SalesOrders'[Order_Date])
var lstdateless90 = lstdate -90
var lstdateless30 = lstdate -30
return
CALCULATE([Total Users], DATESBETWEEN(Dates[Date], lstdateless90, lstdateless30))
 
Date Table. MODELING> New Table

Dates = ADDCOLUMNS ( CALENDAR (FIRSTDATE(Sheet1[ Date]), TODAY()), "year", YEAR ( [Date] ), "MonthNumber", FORMAT ( [Date], "MM" ), "year-month", FORMAT ( [Date], "YYYY-MM" ), "month-year", FORMAT ( [Date], "MM-'YY" ) )

I would format the Dates[Date Field] to a Date like 

Whitewater100_0-1654737367140.png

I hope this helps..

Thank you @Whitewater100 

That worked brilliantly! 

Great! Your welcome..

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors
Top Kudoed Authors