Forum Discussion
Extract values between BeginDate and EndDate then select top 1 where durationInDays is max
Hi comunity ,
Would appreciate any help , because i stuck on task for several days . I need tables in SSAS tabular cube '
'Aрхив Торговых Точек' as there is no appropriate Date column in 'Aрхив Торговых Точек'.
'Aрхив Торговых Точек' . So let's say i have selected date November 2016 .I want code to filter out if selected month and year in filter , falls into range of begindate and enddate , so then it would extract the one in range .But there could more than one Shopid in that date range ,so in this case it should extract the one whose duratioInDays is maximum . So for example ,here is the data in d
database , as you can see there are multiple values for shopid,where November 2016 falls apart
between begindate and enddate . I need to take only that which has the most days in durationInDays column(red marked) and count it as 1.So for each month it would count 1 for only that ShopId which falls into range with the highest value in durationInDays column . I have dax code , which does meet requirements,so for now from the above screenshot it take shopid where duratioIndays = 179 ,for the same filter November 2016 . Thanks in advance .
2 Replies
- Chakravarthy
Resolver II
Anonymous , Create a measure like this.
CALCULATE(AVERAGEx(FILTER(Table,Table[BeginDate]<=max('Date'[Date]) && (ISBLANK(Table[EndDate]) || Table[EndDate]>max('Date'[Date]))),(DATEDIFF(Table[BeginDate],Max('Date'[Date]),Day))),CROSSFILTER(Table[BeginDate],'Date'[Date],None))
- AnonymousNot applicable
Hi ,thanks for your reply . Here is the error message :