Forum Discussion
Using EOMONTH to find quarterly sum
- 6 years ago
Hi Anonymous ,
Believe that you can do two things:
- Make a measure for quarter values (DAX)
- Make a column with the daily figures (M Language)
Option 1.
- Create the following columns on your calendar table:
Quarter = "Q"&QUARTER([Date] -5) End_of_month = EOMONTH([Date]-5;0) //Forcing in both column to pick up th date from 5 days earlier as you have in the monthly calculation.- Add the measure below for the Quartely calculation:
Quarter Reconciled Measure = SUMX ( SUMMARIZE ( Dates; Dates[End_of_month]; "@Date_Selection"; MAX ( Dates[Date] ) ); CALCULATE ( SUM ( FLU_Snapshots[Actual_Value] ); FILTER ( ALL ( FLU_Snapshots[As of date] ); FLU_Snapshots[As of date] = MAX ( [@Date_Selection] ) ) ) )Option 2.
You also may make some query adaptations to get the daily figures:
- Add a step after the last step of your query
- Rigth click the last step on the query settings and select Insert Step after
- Rename this step for example to ====== (this will give you the notion of where you started to add new changes)
- Add a custom column with the following code:
PreviousDay =[As of date] - #duration(1,0,0,0)- Remove the As of Date column
- Insert a Merge Querie
- Do a Merger with the same querie
- Select all columns that are unique identifiers for each row
- On my example only have two (Description and As of Date)
- Do not select the value or any other columns that change within the day otherwise you will get blank values
- Select the left Join
- On the formula bar you will have:
- Table.NestedJoin(#"Step Name", {"Description", "As of date"}, #"Step Name", {"Description", "PreviousDay"}, "Removed Columns", JoinKind.LeftOuter)
- Replace the first Step Name (information highligted above) by the name of the step before the custom step ( ======)
- Expand the Actuals value from New column
- Add a new custom column:
[Actual_Value]-[Removed Columns.Actual_Value]- Remove the column that you expanded before in my case [Removed Columns.Actual_Value]
Now you have daily values for all your KPI not sure if they are of any help but it's one way of getting daily values.
See attach PBIX file.
Hi Anonymous ,
I assume you have a date column on your dataset correct?
If you are using a calendar table to make the relationship with the dataset then you can use the normal time inteligence measures the only thing you need to assure is that the calednar table as continous dates from january 1st to december 31st.
Can you share you model setup please?
Hi Miguel, Yes, I have a date table (you can see it referenced in the formula). It is connected to "as of date" on the Flu_Snapshots table. There are other tables but they are not relevant here. Only the Dates table and the Snapshots table are involved.
- MFelix6 years ago
Super User
Hi Anonymous ,
If you make the calculation based on the timeinteliggence it will work properly:
QTD = TOTALQTD(SUM(Flu_Snapshots[Actual Value]);Dates[Date])This is just an example and can be adjusted, but no need to use EOMONTH formula, except if you don't want to use normal quarters
- Anonymous6 years agoNot applicable
Hi Miguel - Normally that would work. But working with snapshot data is a pain in the a##.
If you see in the visuals I provided earlier, you will note that the filters I have checked say "Flu All Revenue Accounts LP - xxxxx". The "LP" indicates last period (in this case period = month). The xxxxx number is just the sub-account from the accounting ledger.
Our ERP system has other KPI's based on date intervals such as "Flu All Revenue Accounts YTD - xxxxx" etc.
But we do NOT have a daily KPI...and we do not have a Quarterly KPI....very dumb but we don't have either of these. So that is why the normal time intelligence formulas won't work and I was hoping to use an interation of the previously supplied formula.
- MFelix6 years ago
Super User
HI Anonymous ,
Your post is not very clear about what are the calculations made but maybe it's my fault while reading it.
Try to use the ENDOFQUARTER with your previous measure something similar to this:
Monthly Reconciled Measure = VAR _year = SELECTEDVALUE(Dates[Year]) VAR _month = SELECTEDVALUE(Dates[MonthName]) VAR _date = CALCULATE(MIN(Dates[Date]), FILTER(ALL(Dates), Dates[Year] = _year && Dates[MonthName] = _month)) VAR _lastDate = EOMONTH(_date,-0)+5//assumes that numbers will be fully reconciled after 5 days. Values before 5 days may not be fully reconciled VAR _QUARTEREND = ENDOFQUARTER(_lastDate) RETURN CALCULATE(SUM(Flu_Snapshots[Actual Value]),FILTER(ALL(Dates[Date]), Dates[Date] = _QUARTEREND)