Power BI format question

bthumble

Board Regular
Joined
Dec 18, 2007
Messages
231
Hello, I am new to BI and have a couple of questions.

I have added two columns, month and quarter and need help with formatting. Would like the month to be displayed with two numbers. For example 1 would be 01, 2 would be 02, etc. Also the quarter column is displaying 1 and would like it to be displayed as 2024 Q1, 2024 Q2, etc.

Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
How did you add the two columns?
 
Upvote 0
Both added columns are based on a column called posted date. Inserted a new column for each using add column and chose date, then chose

for month chose date then month
for quarter chose date then quarter then quarter of year.
 
Upvote 0
For the month column, the current formula will look something like:

Power Query:
= Table.AddColumn(#"Changed Type", "Month", each Date.Month([Posted date]), Int64.Type)

and you'll need to amend the end of the formula to:

Power Query:
each Date.ToText([Posted date],"MM"), type text)

and for the quarter step, it would end with

Power Query:
each Date.ToText([Posted date], "yyyy")&"Q"&Text.From(Date.QuarterOfYear([Posted date])), type text)
 
Upvote 0
Having issues with the date column. This is what I have
= Table.AddColumn(#"Changed Type", "Month", each Date.Month([Posting Date]), Int64.Type)each Date.ToText([Posted date],"MM"), type text)

getting this alert
Expression.SyntaxError: Token Eof expected.

Am I doing something wrong?
 
Upvote 0
You need to replace everything from the each in the original function with what I suggested, so:

Power Query:
= Table.AddColumn(#"Changed Type", "Month", each Date.ToText([Posting date],"MM"), type text)
 
Upvote 0
Started from scratrch. Highlighted the Posting Date column and then chose Add Column -- Date -- Month -- Month. This is the formula that shows up

= Table.AddColumn(#"Promoted Headers", "Month", each Date.Month([Posting Date]), Int64.Type)

Changed the formula to

= Table.AddColumn(#"Promoted Headers", "Month", each Date.ToText([Posting date],"MM"), type text)

Now the data in the column is showing Error.
 
Upvote 0
What is the data type of the Posting Date column in the previous step? It needs to be Date (not DateTime or any other type).
 
Upvote 0
Is the actual column type date though? The fact that the value in it looks like a date doesn't mean the column type is date.

It might be best if you can post the entire M code from the Advanced editor.
 
Upvote 0

Forum statistics

Threads
1,215,109
Messages
6,123,137
Members
449,098
Latest member
Doanvanhieu

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