I Need a measure that will calculate sum of sales-plan divided by the number of days in month which is selected in slicer? to get daily sales-plan of that month
Then I need to multiply that daily sales-plan on the number of days which are selected in range slicer, to get the sum of that range
For example: I have selected the range from 01/01/21 - 07/01/21/ And I have a quota on January 310$
So I need a measure that will calculate 310/31 = 10, and then I need it to be multiplied by 7 days which is in slicer, and get 70
I am trying to apply this but getting wrong result:
VAR minselectdate = CALCULATE(MIN('calendar'[Date]),ALLSELECTED('calendar'))
VAR maxselectdate = CALCULATE(MAX('calendar'[Date]),ALLSELECTED('calendar'))
VAR StartPeriod = EOMONTH(minselectdate,-1)+1
VAR EndPeriod = EOMONTH(maxselectdate, 0)
VAR Currdate = LASTDATE('calendar'[Date])
VAR Plan = CALCULATE(SUM('Все_отчет1_Квоты'[Квота месяц]),DATESBETWEEN('calendar'[Date],StartPeriod,EndPeriod))
VAR datesperiod = COUNTROWS(DATESBETWEEN('calendar'[Date],StartPeriod,EndPeriod))
VAR planondate = DIVIDE(Plan,datesperiod)
VAR Result = ALCULATE(SUMX(VALUES('calendar'[Date]),planondate),DATESBETWEEN('calendar'[Date], minselectdate,Currdate))
Return
Result
I see you have a calendar table. I will assume it has a relationship to your plan table, and has information on months.
If your filter is on Calendar[Date] and your calendar has monthYear information, you can do this all in a measure as so:
DailyPlanAmount =
CALCULATE (
SUM ( Plan[PlanAmount] ) / COUNTROWS ( 'Calendar' ),
ALL ( 'Calendar'[Date] ),
VALUES ( 'Calendar'[MonthYear] )
)
* COUNTROWS ( 'Calendar' )
We do the sum of plan amounts and use the 'All' function to clear out any filters on date, replacing it with a filter on month. Then we count out the rows (outside our filter) in the calendar table to get a number of days and multiply this against our result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.