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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Add month of all years

evko_0-1634039566796.png

 

 

Hi all PLEASE HELP :******), I need to create a dynamic measure that returns

1. the average of January of each historical year when I'm on Jan 21. When I'm in Feb 21,  return the average of Feb of each historical year etc etc

2. It has to apply an AVERAGEIF condition to only average the range that contains more than 0. E.g., in the above example, i add all the figures but only divided them by 4 instead of 5 periods. 

3. I cannot use time intelligence functions such as MONTH/Dates in periods etc because I have a custom calendar and months are defined by indexes and also month-year numerical formats (202103) 

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

Thanks for your reply.

 

if the week at the end of dec is actually in jan, and the type of date column in your fact table is Date, then try this,  

create a calculated column,

month = IF( [date].[Day]<=21,MONTH([date]),MONTH(EOMONTH([date],1)))

create a measure,

average = CALCULATE(AVERAGE([value]),FILTER(ALL('Table'),[month]=MAX([month])&&[value]<>0))

result

vxiaotang_0-1634795533801.png

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Can we close this thread now if there is no other question? It would be nice if you can accpet my answer as the solution. Thank you very much 🙂

 

 

Best Regards,

Community Support Team _ Tang

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

v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Based on your description, I created a measure, but it needs you to add a standard date column in the data table.  well, it would be better if you can share your sample file, so that we can give you the meausre more in line with your needs.

you can try the measure like

 

Measure = 
    var _today=DATE(2021,1,21)//DATE(2021,2,21)  you can replace it with function to get the current date
    var _historicalMonth=MONTH(_today)
    var _historicalYear=MIN('Calendar Table'[Year])
    var _t=FILTER('Table','Table'[date]<DATE(_historicalYear,_historicalMonth+1,1)&&'Table'[date]>=DATE(_historicalYear,_historicalMonth,1))
    var _total=CALCULATE(SUM('Table'[value]),_t)
    var _countRows=CALCULATE(COUNTROWS('Table'),_t)
return _total/_countRows

 

 

if you need more help, please @ me

 

 

Best Regards,

Community Support Team _Tang

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

Anonymous
Not applicable

Hi xiao tang, thank you so much for the help!!! But unfortunately this cannot work because you have used "MONTH" and i am not able to use the time intelligence functions because our calendar is different. for.e.g,  the week at the end of dec is actually in jan. 

Hi @Anonymous 

Thanks for your reply.

 

if the week at the end of dec is actually in jan, and the type of date column in your fact table is Date, then try this,  

create a calculated column,

month = IF( [date].[Day]<=21,MONTH([date]),MONTH(EOMONTH([date],1)))

create a measure,

average = CALCULATE(AVERAGE([value]),FILTER(ALL('Table'),[month]=MAX([month])&&[value]<>0))

result

vxiaotang_0-1634795533801.png

 

Best Regards,

Community Support Team _Tang

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.