Stay night in same month

msarfaraz

New Member
Joined
Oct 18, 2012
Messages
46
What would be the dax in column "Stay nights in the same month as per system date"

System DateArrivalDepartureStay nights in the Same month as per system date
o1 Jan 202029th Dec 201901 Jan 2020The answer should be 0
12 Jan 202031st Dec 201905th Jan 2020The answer should be 4
28 Jan 202025th Dec 201910th Jan 2020The answer should be 9
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Could you post more examples with expected results with a logic?

its table which connected in BI, the first column is system date and 2nd column is the arrival of guest and third is the departure of the guest, normally system count as stay period i.e. if guest arrival on 29th of Dec 2019 and departure on 1st of Jan 2020 stay night should be 0 (since arrival is on last month and departure on 1st of the month so stay night did not count in current month), however, if arrival on 28th Jan 2020 and departure on 05th Feb system will count only 4 days (28,29,30 and 31st), is there a way we can do the DAX on that. an example is an above scenario.
 

Attachments

  • DAX.JPG
    DAX.JPG
    132.4 KB · Views: 8
Upvote 0
Logic could be Departure - Arrival if the date of the system is before the arrival or equal, otherwise system date - Departure
 
Upvote 0
it could be like this
System DateArrivalDepartureNights
01/01/202029/12/201901/01/20203
02/01/202030/12/201902/01/20203
03/01/202031/12/201903/01/20203
04/01/202001/01/202004/01/20203
05/01/202002/01/202005/01/20203
06/01/202003/01/202006/01/20203
07/01/202004/01/202007/01/20203
08/01/202005/01/202008/01/20203
09/01/202006/01/202009/01/20203
10/01/202107/01/202010/01/2020System > Departure
11/01/202008/01/202011/01/20203
12/01/202009/01/202012/01/20203
13/01/202010/01/202013/01/20203
14/01/202011/01/202014/01/20203
15/01/202012/01/202015/01/20203
16/01/202013/01/202016/01/20203
17/01/202014/01/202017/01/20203
18/01/202015/01/202018/01/20203
19/01/202016/01/202019/01/20203
20/01/202017/01/202020/01/20203
21/01/202018/01/202021/01/20203
22/01/202019/01/202022/01/20203
23/01/202020/01/202023/01/20203
24/01/202021/01/202024/01/20203
25/01/202022/01/202025/01/20203
26/01/202023/01/202005/02/202013
27/01/202024/01/202027/01/20203
28/01/202025/01/202028/01/20203
29/01/202026/01/202031/01/20205
30/01/202027/01/202005/02/20209
31/01/202028/01/202005/02/20208


text value should be change to 0 or null if you want to use numeric values from Nights column

is this OK ?

I'll try with Stays Period now....... :cool:

btw. I'm not doing it with DAX so let me know if you really want DAX
 
Last edited:
Upvote 0
result
System DateArrivalDepartureStays PeriodTotal Nights
01/01/202029/12/201901/01/202003
02/01/202030/12/201902/01/202013
03/01/202031/12/201903/01/202023
04/01/202001/01/202004/01/202033
05/01/202002/01/202005/01/202033
06/01/202003/01/202006/01/202033
07/01/202004/01/202007/01/202033
08/01/202005/01/202008/01/202033
09/01/202006/01/202009/01/202033
10/01/202107/01/202010/01/20203System > Departure
11/01/202008/01/202011/01/202033
12/01/202009/01/202012/01/202033
13/01/202010/01/202013/01/202033
14/01/202011/01/202014/01/202033
15/01/202012/01/202015/01/202033
16/01/202013/01/202016/01/202033
17/01/202014/01/202017/01/202033
18/01/202015/01/202018/01/202033
19/01/202016/01/202019/01/202033
20/01/202017/01/202020/01/202033
21/01/202018/01/202021/01/202033
22/01/202019/01/202022/01/202033
23/01/202020/01/202023/01/202033
24/01/202021/01/202024/01/202033
25/01/202022/01/202025/01/202033
26/01/202023/01/202005/02/2020413
27/01/202024/01/202027/01/202033
28/01/202025/01/202028/01/202033
29/01/202026/01/202031/01/202055
30/01/202027/01/202005/02/202049
31/01/202028/01/202005/02/202048
 
Upvote 0
result
System DateArrivalDepartureStays PeriodTotal Nights
01/01/202029/12/201901/01/202003
02/01/202030/12/201902/01/202013
03/01/202031/12/201903/01/202023
04/01/202001/01/202004/01/202033
05/01/202002/01/202005/01/202033
06/01/202003/01/202006/01/202033
07/01/202004/01/202007/01/202033
08/01/202005/01/202008/01/202033
09/01/202006/01/202009/01/202033
10/01/202107/01/202010/01/20203System > Departure
11/01/202008/01/202011/01/202033
12/01/202009/01/202012/01/202033
13/01/202010/01/202013/01/202033
14/01/202011/01/202014/01/202033
15/01/202012/01/202015/01/202033
16/01/202013/01/202016/01/202033
17/01/202014/01/202017/01/202033
18/01/202015/01/202018/01/202033
19/01/202016/01/202019/01/202033
20/01/202017/01/202020/01/202033
21/01/202018/01/202021/01/202033
22/01/202019/01/202022/01/202033
23/01/202020/01/202023/01/202033
24/01/202021/01/202024/01/202033
25/01/202022/01/202025/01/202033
26/01/202023/01/202005/02/2020413
27/01/202024/01/202027/01/202033
28/01/202025/01/202028/01/202033
29/01/202026/01/202031/01/202055
30/01/202027/01/202005/02/202049
31/01/202028/01/202005/02/202048
Result seems to be ok, can it done in DAX please
 
Upvote 0

Forum statistics

Threads
1,217,383
Messages
6,136,267
Members
450,001
Latest member
KWeekley08

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top