date(year(), month(), 1) doens't work in PowerPivot?

CelineT

New Member
Joined
Mar 10, 2016
Messages
17
Hello,

I have 2 columns with dates that need to be adjusted to 1st of the month if day<15, or next month if day >=15

If I use the date( year(), month() + if(day<15, 0, 1), 1) in excel, it works fine, but in powerpivot it gives an error.


When I break it down in steps:
- date(year(), 1, 1) works fine
- date(year(), month(), 1) doens't work anymore
It seems that PowerPivot blocks as soon as 2 items are made variable.

Anyone have a solution?

Thanks
Céline
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hello Céline,

My guess would be that you do need to specify ...

=date(year(serialnumber), month(serialnumber), 1)

HTH
 
Upvote 0
sorry, tried to be short, between brackets I referred to a column "start date" or "end date".

so the full formula in excel, which works fine, is:
=date( year(start date), month(start date) + if(day(start date)<15, 0, 1), 1)

the "start date" is identified as a date, so I presume Excel stores it as a serial number so that would be fine?
 
Upvote 0
Yes you are right ...

Should you need to make sure your dates are actual serial numbers ...

use the keys Control+1 and select general ...

Hope this will help
 
Upvote 0
This works fine for me in Power Pivot with a date Field1:

=date(year([Field1]),month([Field1])+if(day([Field1])<15,0,1),1)
 
Upvote 0
oh great, I have found my mistake! It wasn't in the formula itself but I had some blanks in the start or end date columns which gave the error. When I added if(isblanck(date); ... ; ...) it worked.

Thanks for taking the time to reply!
 
Upvote 0

Forum statistics

Threads
1,225,726
Messages
6,186,669
Members
453,368
Latest member
xxtanka

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