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.
I'm struggling to get rolling 12 months for the months are completed. For example; For the current month the value should display Zero and for the completed month it should display rolling 12 months values. For 2016-Dec the value=sum(2016-Jan till 2016-Dec), 2016-Nov=sum(2015-Dec till 2016-Nov)
Year | Month | Value |
2016 | 8 | 985193929.9 |
2016 | 9 | 985428542.2 |
2016 | 10 | 985365989.1 |
2016 | 11 | 992519096.7 |
2016 | 12 | 980109375.8 |
2017 | 1 | 0 |
Please suggest any idea, if you have come across the same
Solved! Go to Solution.
you can check if a month is complete with: (Bold Part)
ValueCalc = if(TODAY()>=EOMONTH(VALUES(Table1[DateRef]);0);EXPRTRUE;EXPRFALSE)
Hi @Chinoos,
According to your description, you can refer to below formulas if it works on your side.
1. Calculate the total value from previous date to current date.
Total = var minDate= DATE(YEAR(MAX([Date])),MONTH(MAX([Date]))-11,DAY(MAX([Date]))) return SUMX(FILTER(ALL('Table'),[Date]>= minDate&&[Date]<=MAX([Date])),[Amount])
2. Calculate the rolling total in current year.
Rolling total = SUMX(FILTER(ALL('Table'),[Date]<=MAX([Date])&&[Date].[Year]=MAX([Date].[Year])),[Total])
If above is not help, please share some sample data to test.
Regards,
Xiaoxin Sheng
Thanks the formulas, it worked for rolling 12 months sum, but i had mades some changes since date and measure are coming from 2 different tables. I'm using just one formula to get the result.
Rolling 12 months =
var minDate= DATE(YEAR(MAX('Fiscal Calendar Date'[Fiscal Calendar Date])),MONTH(MAX('Fiscal Calendar Date'[Fiscal Calendar Date]))-12,DAY(MAX('Fiscal Calendar Date'[Fiscal Calendar Date])))
return
CALCULATE( SUM ( 'Sales'[Gross Sales] ),FILTER(ALL('Fiscal Calendar Date'),'Fiscal Calendar Date'[Fiscal Calendar Date]> minDate&&'Fiscal Calendar Date'[Fiscal Calendar Date]<=MAX('Fiscal Calendar Date'[Fiscal Calendar Date])))
Please find the sample date below( from the Fiscal Calendar Date Hierarchy, I'm dsiplaying only the Year and Month)
Year | Month | Gross |
2015 | January | 55039455.96 |
2015 | February | 49964844.34 |
2015 | March | 67875264.74 |
2015 | April | 85248808.27 |
2015 | May | 88028313.78 |
2015 | June | 97662930.16 |
2015 | July | 93672919.35 |
2015 | August | 89597379.02 |
2015 | September | 93686553.51 |
2015 | October | 97872548.47 |
2015 | November | 81438568.72 |
2015 | December | 77867879.91 |
2016 | January | 55328963.33 |
2016 | February | 61547754.60 |
2016 | March | 78241869.13 |
2016 | April | 81956103.71 |
2016 | May | 89760083.71 |
2016 | June | 96347579.89 |
2016 | July | 83884792.87 |
2016 | August | 97057881.05 |
2016 | September | 95230929.74 |
2016 | October | 90063862.46 |
2016 | November | 90997731.83 |
2016 | December | 59691823.46 |
As mentioned earlier, this is actually better suited for DAX, assuming that you've got a full data model in place (eg, a date table). Power Query (ie 'M') has performance issues - for example, if your dataset has a lot of columns in it, then it will run much slower than one that has just a few columns). So you might treat this as an exercise in getting familiar with what is possible in M, even if it's not the best approach.
In DAX, you might try something like this -
using the recommended idea of having building blocks of measures, create a measure for total net sales:
TotalNetSales = SUM( [NETSALES] )
Then a measure for rolling 12month sales:
12MonthRollingSales =
CALCULATE([TotalNetSales],
DATESINPERIOD(DimDates[Date],
LASTDATE(DimDates[Date]),-12, Month
)
)
... that's of course assuming that the fact table is connected to a proper date table (DimDates in my example, where [Date] is every calendar date - provided that MONTH_FISCAL is a proper date, then it can be linked to the date table)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
97 | |
78 | |
63 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |