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
cfrance
Regular Visitor

Restrict DATESINPERIOD measure

Hello I am using the measure below to create a 7 day running average graph but I would like to exclude the last say 5 days data as it gives an average of less than 7 days of full data  - the graph lines drops to zero. Is this possible?  
 
CY22 7 Day Running AV = calculate([Total Weight]/7,DATESINPERIOD('Date Lookup'[Normalized Date],max('Date Lookup'[Normalized Date]),-7,DAY),'Date Lookup'[Crop Year] = 2022)
 
Thank you
1 ACCEPTED SOLUTION

This is the wasy I finally solved this - 

CY22 7 Day Running AV = if(max('Date Lookup'[Normalized Date])>today(),blank(),calculate([Total Weight]/7,DATESINPERIOD('Date Lookup'[Normalized Date],max('Date Lookup'[Normalized Date]),-7,DAY),'Date Lookup'[Crop Year] = 2022))
 
by using an if statement to test if there was data present
 
Thanks 

View solution in original post

5 REPLIES 5
v-jianboli-msft
Community Support
Community Support

Hi @cfrance ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@cfrance Maybe:

CY22 7 Day Running AV = calculate([Total Weight]/7,DATESINPERIOD('Date Lookup'[Normalized Date],max('Date Lookup'[Normalized Date])-5,-7,DAY),'Date Lookup'[Crop Year] = 2022)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you @Greg_Deckler  - I tried adding the -5 days but it looks like it offsets the entire curve by 5 days

 

@crfrance Well, was worth a shot I guess. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

This is the wasy I finally solved this - 

CY22 7 Day Running AV = if(max('Date Lookup'[Normalized Date])>today(),blank(),calculate([Total Weight]/7,DATESINPERIOD('Date Lookup'[Normalized Date],max('Date Lookup'[Normalized Date]),-7,DAY),'Date Lookup'[Crop Year] = 2022))
 
by using an if statement to test if there was data present
 
Thanks 

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.