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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
HenryJS
Post Prodigy
Post Prodigy

Filter: Return Values In Last 14 Days Only

Hi all,

 

How can I add to the below FILTER formula to only return values in the last 14 days?

 

There is a Action Date in the Candidate Actions table (shown below).

 

I would like CV : Job to only return values in the last 14 days.

 

DAX.PNGDAX1.PNG

 

Thanks,

 

Henry

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Create a new column in the table

Date Action = format(Table[Action Date],"mm/dd/YYYY")

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions

 

Then use a formula like

Lat 14 days = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[date],max(Sales[Sales Date]),-14,DAY)) 

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...

https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

11 REPLIES 11
v-diye-msft
Community Support
Community Support

Hi @HenryJS 

 

If the above post helps, could you please consider Accept it as the solution to help the other members find it more quickly. thanks!

If the issue still exists, please kindly share more details, we'd like to provide further helps.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
amitchandak
Super User
Super User

Create a new column in the table

Date Action = format(Table[Action Date],"mm/dd/YYYY")

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions

 

Then use a formula like

Lat 14 days = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[date],max(Sales[Sales Date]),-14,DAY)) 

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...

https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

Thanks for getting back to me.

 

dax3.PNG
 
I am wanting to only return 'CV:Job' (which is a calculated column in table 'Candidates') values for the last 14 days. The 'Action Date' column is in a different table called 'Candidate Actions'.
 
Am I able to edit the above code for 'CV:Job;' to return only values in last 14 days?
 
I cannot work out using previous responses.
 
Thanks,
 
Henry

Please share the relationship Diagram and the current formula in text format.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

Please see below

 

CV:Job = calculate(sum(CandidateActions[Activities]),FILTER(CandidateActions,CandidateActions[ActionName]="CV Sent" && CandidateActions[CandidateRef]=Candidates[CandidateRef]))
 
 
dax10.PNG

I think you should add date calendar (https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions)

 

Try

 CV:Job = calculate(sum(CandidateActions[Activities]),FILTER(CandidateActions,CandidateActions[ActionName]="CV Sent" && CandidateActions[CandidateRef]=Candidates[CandidateRef])
 ,DATESINPERIOD('Date'[date],max(CandidateActions[Date Action]),-14,DAY) )

In case you do not have the calendar then use action date[action date] in place of date[date]

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Perhaps create a "Days Difference"column that calculates the difference in days between today and your date field. Then you can create an "Is within 14 Days Flag" column, that sets the value to either 1 or 0 if the "Days Difference" column is -14 or greater(i.e. -14, -13, -12,...) and less than 0. Next, in your summation Measure, you can calculate the sum based on the "Is within 14 Days Flag" equal to 1.

 

Not sure if the timestamp within your Date field will give you problems with my suggestion but you can always create a new Date field that's formatted without the timestamp and then use this new Date field to perform the above.

parry2k
Super User
Super User

@HenryJS last 14 days from today?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@HenryJS add date table in your model, there are many posts on how to add one. For time intelligence, date table make things easier to work.

 

- Mark date table as date. 

- Set relationship on this date table with your action table and then add following measure

 

Last 14 Days = 
CALCULATE ( 
SUM ( ActionTable[Activities] ),
DATESINPERIOD ( DateTable[Date], TODAY(), -14, DAY )
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k I can't mark as date table because date column can only have one timestamp per day and the date column can't have gaps in dates

 

dax3.PNG

@HenryJS this you are going to do on date table not your activity table



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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