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
csrapp96
Helper I
Helper I

Ideas on how to NOT display dates in visual until a true rolling average period begins

hi all! 

 

I have a DAX function to display a rolling average sales period below:

 

SMA = if(isblank([Values]),blank(),averagex(topn([Parameter Value],calculatetable('date',DATESBETWEEN('date'[Date],max('date'[Date])-10,MAX('date'[Date])),'date'[Custom]=2),[Value of date]),[Values]))
 
The issue is that we would like it to display on the visuals when the rolling average period begins. For example, if the rolling average period is 5 days in the parameter, it would display from day 6 onward. If it is 30 days, it would display from day 31 and onward. This is to discount the period that is not a true rolling average. 

It get's challenging because I only want to do this for trading days where "Custom=2" signifies a trading day. 

Is there a good way to achieve this?

Edit: Sample data can be found here
 
THANK YOU!
4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1655411227750.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

this is great stuff @CNENFRNL !! it's on the right track to the functionality needed

 

the one edit I need is for it to count "trading days" signified by "Custom = 2" rather than all days. so if the parameter is 10, it should go to the 10th "trading day" or day with data which is January 14th instead of January 11th. Basically, I need it to not count the weekend/holidays. 

 

For some reason, filters on "Custom = 2" in the "SHOW" measure are not working. any idea to what I am doing wrong? it goes to January 13 instead of the 14th with the filter on the measure. Thanks so much!! Updated file with filter is here. 

 

See below: 

 

csrapp96_1-1655493219391.png

 

 

csrapp96_0-1655495177752.png

 

 

Greg_Deckler
Super User
Super User

@csrapp96 Wrap your code in another IF statement that checks if the MAX [Date] is within the specified range. If not, return BLANK. Hard to be more specific without sample data, etc.


@ 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 - makes sense! I've been trying something similar, I am just having trouble executing it correctly. 

 

sample data can be found here

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.