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
corange
Post Patron
Post Patron

Rolling Avg Period to Period without non trading day

Hi everyone, 

 

Can someone help with my formula. 

 

I am trying to calculate a daily rolling average / period (month divided into two) and which will exlude non-trading days. 

 

The following formula works but I want the daily average wihch is based on the number of trading days in each period For each day, I have got a column using 1 / 0 if it is a trading / non trading day. 

 

My formula is like that at the moment but I dont know how to go about removing non trading days: 

 

Value rolling average = (SUM(SummaryBI[Value]) / CALCULATE(DISTINCTCOUNT('Calendar'[Period]),
DATESINPERIOD('Calendar'[Date],
LASTDATE('Calendar'[Period]),-3,MONTH), FILTER('Calendar', 'Calendar'[TradingDay]=1)))
 
I am thinking of changing CALCULATE(DISTINCTCOUNT('Calendar'[Period]) to CALCULATE(DISTINCTCOUNT('Calendar'[Date]). 
 
Can someone help me work on the formula a bit so it only includes trading days in my rolling average? 
 
Thank you. 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@corange 

In your have the trading date 

 

Trading Date = if('Calendar'[TradingDay]=1,Calendar'[Period]), blank())

 

Now use distinctcount of trading Date. Power bi may count blank as one additional so reduce it from the distinct count

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@corange 

In your have the trading date 

 

Trading Date = if('Calendar'[TradingDay]=1,Calendar'[Period]), blank())

 

Now use distinctcount of trading Date. Power bi may count blank as one additional so reduce it from the distinct count

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.