Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello to all,
I'm stuck with a simple task from a while now. I have a table that contains fields as follow:
Date: W/O id:
2016-01-01 F7895
2016-01-01 A89764
2016-01-15 987643
2016-02-02 B98765
...
...
2016-12-31 F796435
And so on. What I'm trying to do is to count the quantity of W/O by month period then summarize that with a 3 month moving window. For example, we will sum the quantity of W/O from 2016-10-01 up to 2016-12-31. Then the next month, the value will go from 2016-11-01 up to 2017-01-31. I have searched the forum and tried lot of formula but nothing resolve my issues. Any ideas and help will be greatly appreciated.
Thank you!
Solved! Go to Solution.
I think this might be close to what you need?
3 Month RT MEASURE = CALCULATE ( COUNTROWS ( DATESINPERIOD ( 'Table'[Date], LASTDATE('Calendar'[Date]),-3,MONTH) ), FILTER ( 'Calendar', 'Calendar'[Full Month] = "Full Month" ) )
Do you have a Calendar Table?
And
You only want to count full/completed months right?
I do have a calendar table however I would prefer to use the date that already exist in my table. And yes I want full/completed months calculation.
Thank you!
1) Create a COLUMN in your Calendar Table
Full Month = IF ( TODAY () >= EOMONTH ( 'Calendar'[Date], 0 ), "Full Month", "Incomplete Month" )
2) And then the 3 Month RT MEASURE
3 Month RT MEASURE = CALCULATE ( COUNTROWS ( Table ), DATESINPERIOD ( Table[Date], CALCULATE ( LASTDATE ( 'Calendar'[Date] ), FILTER ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Full Month] = "Full Month" ) ), -3, MONTH ) )
As I posted yesterday DATESINPERIOD works even without a Calendar Table
as you see in formula above the Table[Date] column - the 1st argument is your Table not the Calendar
we only use the Calendar to get the last date of the last full month
Hope this helps!
Ok I will give a try. I have already tested with DatesInperiod function in the past but not exactly as you did. I will let you know.
Thank you!
Ok I did test the formula you provided me. However, I still get a monthly value while I want a cumulated value.
Ex.: September 2016 will hold the value that sum all the WO from a 3 month period , Jully 2016 up to September 2016 and so on up January 2017 that will hold value of November 2016 up to January 2017. Each month must display the sum of last 3 month period. I hope I'm precise enough. Thanks for your help!
I think this might be close to what you need?
3 Month RT MEASURE = CALCULATE ( COUNTROWS ( DATESINPERIOD ( 'Table'[Date], LASTDATE('Calendar'[Date]),-3,MONTH) ), FILTER ( 'Calendar', 'Calendar'[Full Month] = "Full Month" ) )
Okay I think we got it now!
1) Create a COLUMN in your Calendar Table
Full Month COLUMN = IF ( TODAY () >= EOMONTH ( 'Calendar'[Date], 0 ), "Full Month", "Incomplete Month" )
2) And then this NEW MEASURE
3 Completed Months Running Total MEASURE = VAR LastCompleteMonthDate = CALCULATE ( LASTDATE ( 'Calendar'[Date] ), FILTER ( 'Calendar', 'Calendar'[Full Month] = "Full Month" ) ) VAR FirstDate3MonthsPrior = CALCULATE ( FIRSTDATE ( 'Calendar'[Date] ), DATESINPERIOD ( 'Calendar'[Date], LastCompleteMonthDate, -3, MONTH ) ) RETURN CALCULATE ( [YOUR MEASURE], DATESBETWEEN ( 'Calendar'[Date], FirstDate3MonthsPrior, LastCompleteMonthDate ) )
Obviously I deliberately used long descriptive Variable names which you can change
but now this can be easily adjusted by only changing the number in red!
Good Luck!
Hi Sean,
Thanks for that information, it´s works !!!
Maybe you can help me with a variation, first i am explain what i doing.
1) with your formula i create those measure
1.-sumarize of cost
suma_costo_neto_12_meses_movil = VAR LastCompleteMonthDate = CALCULATE ( LASTDATE ( 'Date'[Fecha] ); FILTER ( date; 'Date'[ultimo_mes_completo] = "Full Month" ) ) VAR FirstDate3MonthsPrior = CALCULATE ( FIRSTDATE ( 'Date'[Fecha] ); DATESINPERIOD ( 'Date'[Fecha]; LastCompleteMonthDate; -12 ;MONTH) ) RETURN CALCULATE ( SUM('Table1'[COSTO]); DATESBETWEEN ( 'Date'[Fecha]; FirstDate3MonthsPrior; LastCompleteMonthDate ) )
2.- average of sales
prom_Colocaciones_12_meses_movil = VAR LastCompleteMonthDate = CALCULATE ( LASTDATE ( 'Date'[Fecha] ); FILTER ( date; 'Date'[ultimo_mes_completo] = "Full Month" ) ) VAR FirstDate3MonthsPrior = CALCULATE ( FIRSTDATE ( 'Date'[Fecha] ); DATESINPERIOD ( 'Date'[Fecha]; LastCompleteMonthDate; -12 ;MONTH) ) RETURN CALCULATE ( divide(SUM('Table1'[Venta]);12); DATESBETWEEN ( 'Date'[Fecha]; FirstDate3MonthsPrior; LastCompleteMonthDate ) )
3.- resultado (this is the division of the previous ones)
resultado = [suma_costo_neto_12_meses_movil] / [prom_Colocaciones_12_meses_movil]
so if i dont use the dimension date the resultado is perfect but when i use this dimension (because i want to see the evolution of this index) the resultado change for
resultado = cost of this month / ( sales of this moth / 12)
the result when i want is a division of rolling 12 month [sumarize cost / (sumarize sales/12) ] for each month
In green i put the result with your formula with out date dimension
In blue the result i want for the other month
In red the result with the dimension date
Date | Costo | Sales | resultado obtenido | resultado deseado |
01/08/2017 | 14.316.069.700,00 | 13.320.449.570.495,00 | ||
01/09/2017 | 16.939.617.793,00 | 13.394.740.922.262,00 | ||
01/10/2017 | 14.680.033.193,00 | 13.458.750.519.748,00 | ||
01/11/2017 | 8.871.789.874,00 | 13.605.301.094.424,00 | 0,78% | |
01/12/2017 | 13.122.665.980,00 | 13.663.005.198.515,00 | 1,15% | |
01/01/2018 | 16.807.983.599,00 | 13.720.491.064.445,00 | 1,47% | |
01/02/2018 | 17.209.388.491,00 | 13.749.363.547.223,00 | 1,50% | |
01/03/2018 | 16.278.829.972,00 | 13.887.556.595.776,00 | 1,41% | |
01/04/2018 | 14.253.829.989,00 | 13.980.895.401.675,00 | 1,22% | |
01/05/2018 | 13.394.442.739,00 | 14.072.419.517.952,00 | 1,14% | |
01/06/2018 | 14.763.259.834,00 | 14.206.538.166.274,00 | 1,25% | |
01/07/2018 | 15.806.333.890,00 | 14.299.342.357.065,00 | 1,33% | 1,2804% |
01/08/2018 | 42.876.304.751,00 | 14.513.141.349.238,00 | 3,55% | 1,4771% |
01/09/2018 | 20.094.809.245,00 | 14.617.464.241.314,00 | 1,65% | 1,4889% |
01/10/2018 | 15.389.926.467,00 | 14.835.472.808.712,00 | 1,24% | 1,4818% |
I hope you can help me
thanks of before hand
Thank you Guys! With all your help and the final solution from Phil it works great, exactly what I need.
Have a good day!