Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors