Forum Discussion
An argument or function DATE has wrong data type will not resolve
- 3 years ago
Devtr I see the issue, sometimes _First_Arr_Date is BLANK.
Try this:
LY_Past_Res_Rooms = var _First_Arr_Date = FIRSTDATE('FutureReservations'[arrival_date]) return if(_First_Arr_Date = BLANK(), BLANK(), var _LY_First_Arr_Date = DATE(YEAR(_First_Arr_Date)-1,MONTH(_First_Arr_Date),DAY(_First_Arr_Date)) var _Last_Dep_Date = LASTDATE('FutureReservations'[departure_date]) var _LY_Last_Arr_Date = DATE(YEAR(_Last_Dep_Date)-1,MONTH(_Last_Dep_Date),DAY(_Last_Dep_Date)) var _Result = CALCULATE(COUNT('Past_Reservations'[rate_cat]), FILTER(ALL('Past_Reservations'[arrival_date]), 'Past_Reservations'[arrival_date]>=DATEVALUE(_LY_First_Arr_Date) && 'Past_Reservations'[arrival_date]<DATEVALUE(_LY_Last_Arr_Date) && 'Past_Reservations'[arrival_date]<>BLANK())) return _Result )
Devtr I am unable to recreate (see attached PBIX below signature). But, I don't know what group_bda is either so can't recreate 100%.
- Devtr3 years agoHelper III
Sorry but I have attached the file already.
Did it not work?
Group_bda divides the booked_days_in_adv values into groups.
0 (reservation booked on same day)
1(one day ago)
...
6-10 (six to ten days ago)
...
Thanks.
- Greg_Deckler3 years agoCommunity Champion
Devtr I missed the download link and just used the tables you posted, give me a minute.
- Greg_Deckler3 years agoCommunity Champion
Devtr I see the issue, sometimes _First_Arr_Date is BLANK.
Try this:
LY_Past_Res_Rooms = var _First_Arr_Date = FIRSTDATE('FutureReservations'[arrival_date]) return if(_First_Arr_Date = BLANK(), BLANK(), var _LY_First_Arr_Date = DATE(YEAR(_First_Arr_Date)-1,MONTH(_First_Arr_Date),DAY(_First_Arr_Date)) var _Last_Dep_Date = LASTDATE('FutureReservations'[departure_date]) var _LY_Last_Arr_Date = DATE(YEAR(_Last_Dep_Date)-1,MONTH(_Last_Dep_Date),DAY(_Last_Dep_Date)) var _Result = CALCULATE(COUNT('Past_Reservations'[rate_cat]), FILTER(ALL('Past_Reservations'[arrival_date]), 'Past_Reservations'[arrival_date]>=DATEVALUE(_LY_First_Arr_Date) && 'Past_Reservations'[arrival_date]<DATEVALUE(_LY_Last_Arr_Date) && 'Past_Reservations'[arrival_date]<>BLANK())) return _Result )- Devtr3 years agoHelper III
Thank you Greg_Deckler for your quick reply and time.
As soon as I get a chance tomorrow, I will apply this.
I am pretty sure it will work.
Again I really appriciate your support and experise.