How can I dynamically reference cells containing dates in cubemember formula - excel

I have converted my Cube Pivot table to formulas using OLAP Tools > Convert to formulas.
The column labels are dates in UK format, which is fine. The CUBEMEMBER formula is as such:
=CUBEMEMBER("Name of Cube","[Date].[Display Date].&[27/01/2017]")
This is the issue:
If i copy and paste the date 27/01/2017 in this exact format (For example), and paste it above the cell that has the CUBEMEMBER formula, i can succesfully replace the member_expression part with that cell reference in 2 ways:
One: =CUBEMEMBER("Name of Cube","[Date].[Display Date].&["&B8&"]")
Two: =CUBEMEMBER("Name of Cube",B8)
I do not want to have to copy and paste dates, then link to those cells in order for it to work. I want to be able to link to a cell that already has a date in it. The difference is that its not in the EXACT same format as cubemember. Even if i copy the formats of the date, it does not work.
Any guidance??

Dates are stored as numbers in Excel. The way to get the date as you want it is by using TEXT. With Swedish number formats in Windows the date can be shown as text by using this formula:
=TEXT(A1;"ÅÅÅÅ-MM-dd")
the "ÅÅÅÅ" part should probably be "yyyy" or "YYYY" for UK formats and could of course be "dd/MM/yyyy".

Related

Extracting substr and concat In Excel not working as it should

So I have an excel file which has a date column in the format mm/dd/yyyy Like in this picture:
I want it in the format dd/mm/yyyy and i tried formatting the cells but they dont change. at last I chose to simply extract and concat the dates in a new column but it works for some cells while with others not.. this is the result:
As you can see sometimes it works and sometimes not. this is the formula I used (please bear in mind I am just starting out with excel and I have no clue of tricks or other methods) :
what is causing the faulty results in some of the cells ? TIA
Edit: Link for the data https://data.world/markbradbourne/rwfd-real-world-fake-data/workspace/file?filename=Call+Center.csv
If they are true date then can use-
=TEXT(A2,"dd/mm/yyyy")
If they are date format stored as text then can try-
=TEXT(DATEVALUE(A2),"dd/mm/yyyy")
If you need to extract strings then concat and convert to dates then try-
=DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,4,2))
You should use the DATE formula and then format as you need
=TEXT(DATE(RIGHT(E2,4),MID(E2,4,2),LEFT(E2,2)),"dd/MM/YYYY")
DATE formula takes Year, Month, Day as parameter - and converts that into a valid date.
TEXT then does the formatting for the output
Perhaps you should first try in using Text To Columns which in built in Excel, Under Data Tab, Grouped under Data Tools,
So just select those range, Goto Data Tab --> Click On Text To Columns --> Then select Delimited in the First Step --> Next --> Next as well in the Second Step --> and in the Third Step click on Date and change it to MDY and change the destination to adjacent cell and press Finish.
Since Dates & Times are stored as Numbers in Excel hence it will return you as numbers therefore you just need to format it as dd/mm/yyyy by pressing CTRL 1 --> Format Cells dialog opens --> under Number Tab --> Click on Custom and type by removing the General --> dd/mm/yyyy.
Using TEXTJOIN() & MID() Functions, assuming you are using either Excel 2019/2021 or MS365
• Formula used in cell B2
=TEXTJOIN("/",,MID(A2,{4,1,7},{2,2,4}))+0

Excel date conversion to day of the week: not working after 1 row

I want to get days of the month corresponding to each particular dates in a column in Excel (Note that I am using the web version of office Excel).
The formula =TEXT(A2,"dddd") works correctly for the first row and then when applied to the later rows does not perform as needed. It returns the same date and not the weekday. I have checked the format of the cells, and it is all sent to General.
See the attached image for reference, the formula worked in C2, and not after that.
Note: I have inserted a table for the required range.
Not Recognizing d/m/yyyy
For cell A2 you can use this formula instead (in cell C2):
d/m/yyyy (Your Case)
=TEXT(DATE(VALUE(RIGHT(A2,LEN(A2)-FIND("/",A2,4))),VALUE(MID(A2,FIND("/",A2)+1,FIND("/",A2,4)-FIND("/",A2)-1)),VALUE(LEFT(A2,FIND("/",A2)-1))),"dddd")
m/d/yyyy (Someone else might need this.)
=TEXT(DATE(VALUE(RIGHT(A2,LEN(A2)-FIND("/",A2,4))),VALUE(LEFT(A2,FIND("/",A2)-1)),VALUE(MID(A2,FIND("/",A2)+1,FIND("/",A2,4)-FIND("/",A2)-1))),"dddd")

Excel VBA - Text to Date after running macro in a single Row

I have several Macros running at once in a file. The output pastes unique dates from B1:Z1 on the next sheet. The dates right now are pasting as ex. 43619 instead of 6/3/2019. I have been troubleshooting this but everything I have found is a whole column instead of rows. Thanks!
To Excel a Date is a number(the number of days since 1/1/1900). The number is formatted to look like a date.
If you are just pasting the values the format is not following and as such the value is reverted to the number.
To apply the formatting just use:
Worksheet("Sheet1").Range("B1:Z1").NumberFormat = "mm/dd/yyyy"
Changing the sheet name to your desired sheet and the number format to the format desired.

How to check date format in Excel

I have around 20,000 records in an Excel file and around four columns which have dates. I am trying to insert those into SQL. However date columns have dates in incorrect format eg; 02/092015 or 02/90/2015 or 2015. So checking 20,000 records one by one would be very lengthy.
I tried to count / but it didn't work. It changes the format of column to date.
I was looking for some formula which can check the format and maybe color the cell or something like it.
I was running across this issue today, and would like to add on to what nekomatic started.
Before we begin, the TEXT formula needs to follow the date format we are working with. If your dates are in month/day/year format, then your second argument for the TEXT formula would be "mm/dd/yyyy". If it is in the format day/month/year, then the formula would need to use "dd/mm/yyyy". For the purposes of my answer here, I am going to have my dates in month/day/year format.
Now, let's assume that cell A1 contains the value 12/1/2015, cell A2 contains the value monkey, and cell A3 contains the value 2015. Further, let's assume our minimum acceptable date is December 1st, 2000.
In column B, we will enter the formula
=IF(ISERROR(DATEVALUE(TEXT(A1,"mm/dd/yyyy"))),"not a date",IF(A1 >=DATEVALUE(TEXT("01/01/2000","mm/dd/yyyy")),A1,"not a valid date"))
The above formula will validate correct dates, test against non-date values, incomplete dates, and date values outside of an acceptable minimal value.
Our results in column B should then show 12/1/2015, not a date, and not a valid date.
Two of the examples you give are text which may be identified with Conditional Formatting by applying a formula rule such as:
=ISTEXT(A1)
and colouring the result as you wish. There would be an issue if all your dates (even those of valid format) are also text but I'm guessing that is not the case.
For the third example (ie 2015) a CF formula rule such as:
=AND(A1<2500,A1>0)
may help.
If your columns are a mixture of what should be dates and other entries that are properly text strings your approach may be better than the more general ISTEXT, for example a CF formula rule of:
=FIND("/",A1)>0
If you can add a column to the Excel sheet with the formula
=DATEVALUE(TEXT(A1,"dd/mm/yyyy"))
this should return #VALUE if the contents of A1 are not a valid date in dd/mm/yyyy format. You can filter on this value to identify the incorrect records.
Edit: If A1 contains only 2015 this formula returns 07/07/1905 (if the formula cell is formatted as date) so you can spot these by filtering for dates before the earliest correct date your file should contain.

excel date time cell being covertet to numeric and cant stop it

i have two sheets the first one to call a value from the second sheet, in the first sheet i have
=IFERROR(VLOOKUP(B2,'sheet'!B5:'sheet'!I2500,8,FALSE),"")
this works fine for all full text fields
but when i have a date time of
04/26/2013 11:27:00
it converts it to 41390.47708
if i manually edit the cell and put in an apostrophe it is fine but if i try and use a macro or another column to add the apostrophe it changes it to a number and then adds the apostrophe.
is there a way to get the formula to treat the cell as text
When you use a function like VLOOKUP it only retrieves the underlying value from the referenced cell, not the formatting (and display of date and time is achieved by formatting) - can't you just format the cell with the formula in the required format?
Right-click on the cell and choose Format Cells > Number > Custom and type this in the box
mm/dd/yyyy hh:mm:ss
If the formula might retrieve text or a date/time you can still format it that way because the text will be unaffected

Resources