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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
YasminYas
Helper I
Helper I

Last 30 days,last 180 days based on date slicer

Hello,
I have a report which shows Last 30 days ,Last 90 and till last 366+days. The data will be shown based on Last day of activity slicer. So i want to calculate the data based on date which i will be giving , For example I have given today's date in slicer data should be calculated  accordingly for last 30days , 60 days till last 366+days.
 Capture.PNG
Help is appreciated 
Thanks in advance

7 REPLIES 7
Anonymous
Not applicable

Hi @YasminYas,

 

I'd like to suggest you take a look at following blog, it told about use slicer and dax formula to display last n periodic of amount:
Slicers For Selecting Last "X" Periods

 

Regards,

Xiaoxin Sheng

MFelix
Super User
Super User

Hi @YasminYas,

 

Without further specification on your needs and a sample of data is difficult to give you a good answer.

 

However I think you need to do something like:

 

Last 30 days =
CALCULATE (
    SUM ( Table[Column] );
    FILTER (
        ALL ( Calendar[Date] );
        Calendar[Date] <= MAX ( Calendar[Date] )
            && Calendar[Date]
                >= MAX ( Calendar[Date] ) - 30
    )
)

You should replace the 30 by the number that you need for the additional values.

 

Again without further information is difficult to help you.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Can I ask where should I apply this measure at? The measure works, but if I drop it into any card, slicer, the visual broke.

Hi @leahYan,

This measure can be used in any type of visialization. There should not be any limitations.

What is the context you are using for the measure?

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



It's "Invalid OADate value '64037098'. Accepted values are between -657435.0 and 2958465.99999"

Thank you 
But my requirement is i need to create 4 calculated column for last 30 days, last 90 days, last 180 days. The values in the columns should get calculated every time with User input date. And the values for last 30 days should be 1 if last activity date is active other wise null. 
How can i create these calculated columns with user input date selected in slicer?

Hi @YasminYas,

You cannot have a value on a slicer and change the value of a column, using a measure is the way to go.sonce you can change the context of the calculations based on slicer, filters or other interactions between the visuals.

Why so you need to create columns specifically?

Can you also share a sample of the data model?

Regards,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.