Forum Discussion
Average Per Cover Depends for Dynamic Time Period
You requirement is not clear for me, what visual would you like to use? Based on my understanding, to get the averages of Year,Quarter or Month, you can follow below steps.
- Create a calender table and build up the relationship.
Date = ADDCOLUMNS ( CALENDAR ( MIN('Table'[DT]), MAX('Table'[DT]) ), "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), "Quarter", "Q" & FORMAT ( [Date], "Q" ), "Year", YEAR ( [Date] ), "Monthnumber", FORMAT ( [Date], "MM" ) ) - Create individual measures and use a Multi-row card.
YearCount = CALCULATE ( DISTINCTCOUNT( 'Date'[Year]), 'Table' ) YearAVG = SUM('Table'[QTY])/ CALCULATE ( DISTINCTCOUNT( 'Date'[Year]), 'Table' ) QuarterCount = CALCULATE ( DISTINCTCOUNT( 'Date'[Quarter]), 'Table' ) QuarterAVG = SUM('Table'[QTY])/ CALCULATE ( DISTINCTCOUNT( 'Date'[Quarter]), 'Table' ) MonthCount = CALCULATE ( DISTINCTCOUNT( 'Date'[Monthnumber]), 'Table' ) MonthAVG = SUM('Table'[QTY])/ CALCULATE ( DISTINCTCOUNT( 'Date'[Monthnumber]), 'Table' )
If you have any question, feel free to let me know.
Eric_Zhang Thanks for your reply , I am using the "Line & cluster chart" and if you see in below image covers line going up and down as per month i want a straight line which passes thru and shows me this is an average of month for complete year.
- Eric_Zhang10 years agoMicrosoft Employee
A strike-through straight line can be easy in a certain dimension, but so far I have no idea on creating a measure that would vary when drilling down to Year,Quarter,month or day(I doubt it possible?), that's why I used a multi-row card instead.
For example, an 12 months‘ average straight line passes through months.MonthAVG = CALCULATE(SUM('Table'[QTY]),ALL(Table))/ CALCULATE ( DISTINCTCOUNT( 'Date'[Monthnumber]), 'Table' )If you have any question, feel free to let me know.
- Eric_Zhang10 years agoMicrosoft Employee
A follow up. I've found another dynamic way that can cover Year,Quarter,Month level, however it won't work in day level.
The test pbix is attached for your reference. Please follow below steps.- The dataset is as
- Add the column [MONTH] in 'Table'.
- Add the table 'SummarizedTable'.
- Add the column [MonthlyAVG] in 'SummarizedTable'
- Create a Many to 1 relationship between 'Table' and 'SummarizedTable'.
- Show in the visual
More details about the steps are in the attached pbix. If you have any question, feel free to let me know.
- Rahul_Bhatt10 years agoAdvocate I
Eric_Zhang i am still facing the issue Please find the data model and test it on the secnario where for some years data starts 8 and like that .please download the test data.PIBX from below link.
- The dataset is as