Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
My query is related to Restaurant Point of view, we are looking for a solution which gives me “Average Per cover straight line” should come on graph depends on time period like if we look it for years then total covers divide by Number of years , quarter, month ,days and so on. E.g. if covers Sum 1000 and total years are 4 then 1000/4 in same manner if we go for quarter then 1000/4 if we again drill down and go for month then 1000/12 and so on.
.
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.
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" ) )
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.
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.
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.
More details about the steps are in the attached pbix. If you have any question, feel free to let me know.
@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 peak&valley and caused by the absent months. I've created a calender table to fill up the missing months, please check the attachment. By the way, I was testing on the latest May's release, please upgrade your Power Bi desktop if you can't open the pbix.
Please accept it as solution if the the attaced pbix works, thanks. 🙂 If you have any question, feel free to let me know.
HI @Eric_Zhang this solution doest not work in case when we select a specific year, its giving me solution in case of all the year selected but what if i use slicer and select the year from that , in that its not working.
User | Count |
---|---|
102 | |
91 | |
87 | |
79 | |
71 |
User | Count |
---|---|
113 | |
105 | |
101 | |
75 | |
64 |