Skip to main content
|

PowerPivotPro's FAQ Site

Go Search
  
PowerPivotPro's FAQ Site > The Great PowerPivot FAQ > Converting dates to day of week  

The Great PowerPivot FAQ: Converting dates to day of week

Title

Converting dates to day of week 

Answer

I have a column of dates. Can I convert those to weekday names like Monday, Tuesday, ...?
 
In the PowerPivot window, add a new calculated column with:
=CONCATENATE(Weekday(Table1[Date],2),Format(Table1[Date]," - dddd"))
 
Breaking this down:
=Weekday(date,2) gives you 1 for Monday, 2 for Tuesday, ... 7 for Sunday.
 
Format(Date," - dddd") will return the day of the week spelled out with a leading space, dash, space.
 
Concatenating those together will give you:
1 - Monday
2 - Tuesday
3 - Wednesday
and so on.
 
Why append the numbers before the names? Because PowerPivot won't respect the order of items in Excel's Custom Lists dialog, so your days of the week will not appear in order like they would in a regular pivot table. By appending the number before the weekday name, you can get things to appear in sequence.
 
Are there other formats?
=Format(date,"ddd") will give you "Mon"
=Format(date,"mmm") will give you "Jan"
=Format(date,"mmmm") will give you "January"
 
 

Client/Server

Client 

Topic

F - Calculations (DAX) 

Purpose

Information 

Answered?

Yes 

Contributor

Bill Jelen 

Título

Convertendo datas em dias da semana 

Resposta

Eu tenho uma coluna de datas. Posso converter para dias da semana: Monday, Tuesday (mantive em inglês pois a saída será os dias da semana em inglês).
 
Na janela do PowerPivot, clique para adicionar uma nova coluna calculada com:
 
=CONCATENATE(Weekday(Table1[Date],2),Format(Table1[Date]," - dddd"))
 
Separando:
 
=Weekday(date,2) te retorna 1 para Monday, 2 para Tuesday, ... 7 para Sunday.
 
Format(Date," - dddd") retornará o dia da semana separado com um espaço, traço, espaço.
 
Concatenando ambos, você terá:
1 - Monday
2 - Tuesday
3 - Wednesday
e assim por diante.
 
Por que concatenar os números antes dos nomes? Porque o PowerPivot não respeita a ordem dos itens das listas customizadas. Isso faria os dias da semana não aparecerem na ordem que deveriam em uma pivot table normal. Concatenando ao nome, o número, você terá um resultado em sequencia.
 
Existe algum outro formato?
=Format(date,"ddd") te retornará "Mon"
=Format(date,"mmm") te retornará "Jan"
=Format(date,"mmmm") te retornará "January"

Frage

Wie konvertiere ich Datumswerte nach Wochentagen? 

Antwort

 

preRTM

 
Attachments
Created at 1/14/2010 9:14 AM  by Bill Jelen 
Last modified at 4/23/2010 1:27 PM  by Jochen Juelke