Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
I want to caluclate the average sales for only completed months in the year.
Desire result = Average sales from Jan - Sept given today is October 14th
Thanks,
D
Solved! Go to Solution.
Hi,
Create a Calendar Table with calculated column formulas for Year, Month name and Month number. Sort the Month name by the Month number. Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table. Create a slicer of Year (from the Calendar Table) and select 2022. Write these measures:
Total = sum(Data[Sale])
Average sales till end of previous month = averagex(summarize(calculatetable(calendar,datesbetween(calendar[date],min(calendar[date]),eomonth(today(),-1))),calendar[year],calendar[month name],"ABCD",[Total]),[abcd])
Hope this helps.
Hi,
Create a Calendar Table with calculated column formulas for Year, Month name and Month number. Sort the Month name by the Month number. Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table. Create a slicer of Year (from the Calendar Table) and select 2022. Write these measures:
Total = sum(Data[Sale])
Average sales till end of previous month = averagex(summarize(calculatetable(calendar,datesbetween(calendar[date],min(calendar[date]),eomonth(today(),-1))),calendar[year],calendar[month name],"ABCD",[Total]),[abcd])
Hope this helps.
Thank you. It worked perfectly.
You are welcome.
@dakins , Try a measure like
YTD Today =
var _min = eomonth(today(),-1*month(today()))+1
var _max = if(today() = eomonth( today(),0),eomonth( today(),0),eomonth(today(),-1))
return
CALCULATE(AverageX(values('Date'[Date]) ,[Net]), FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
User | Count |
---|---|
131 | |
108 | |
101 | |
67 | |
64 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |