March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello
I have a database connected via DirectQuery to my panel, in which there is a graph in which, starting from a date type with dd/mm/y format I have gone to a yyamm format and it works well.
Now I want the X axis (the date axis) to appear a date with a user-friendly format (type (mmm yy). I've tried using the Date function in DAX but it doesn't allow it in DirectQuery.
Any ideas on how to do it?
Thank you so much.
Solved! Go to Solution.
Hi @Syndicate_Admin ,
I have tried some effective ways like FORMAT() function , "Split" feature , M syntax below and so on... None worked when using Direct Query mode. So you may need to switch to Import mode.
Date.MonthName([Date]) &" "
& Text.End(Text.From( Date.Year([Date])),2)
Or with DQ mode, please follow these steps that could successfully get the expected format on my side.
In Power Query
1. Right-click Date column to Duplicate the DateTime column --> Change type to Text
2. Click "Add Column" tab -->Use Text.Start() to add a custom column to get "mmm"
Text.Start([#"Date - Copy"],3)
3.Select Date column-->Click "Add Column" tab -->Date-Year only
4. Add custom column:
=[mmm]&" "& Text.End( Text.From([Year]),2)
5. Remove unnecessary columns, below is the final table:
The whole M syntax:
let
Source = Sql.Database("WX-85154\MSSQLSERVER01", "Eyelyn Test"),
dbo_DateValue = Source{[Schema="dbo",Item="DateValue"]}[Data],
#"Duplicated Column" = Table.DuplicateColumn(dbo_DateValue, "Date", "Date - Copy"),
#"Changed Type" = Table.TransformColumnTypes(#"Duplicated Column",{{"Date - Copy", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "mmm", each Text.Start([#"Date - Copy"],3)),
#"Inserted Year" = Table.AddColumn(#"Added Custom", "Year", each Date.Year([Date]), Int64.Type),
#"Added Custom1" = Table.AddColumn(#"Inserted Year", "mmm yy", each [mmm]&" "& Text.End( Text.From([Year]),2)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Year", "Date - Copy", "mmm"})
in
#"Removed Columns"
Now you could use mmm yy column as X-axis:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Syndicate_Admin ,
I have tried some effective ways like FORMAT() function , "Split" feature , M syntax below and so on... None worked when using Direct Query mode. So you may need to switch to Import mode.
Date.MonthName([Date]) &" "
& Text.End(Text.From( Date.Year([Date])),2)
Or with DQ mode, please follow these steps that could successfully get the expected format on my side.
In Power Query
1. Right-click Date column to Duplicate the DateTime column --> Change type to Text
2. Click "Add Column" tab -->Use Text.Start() to add a custom column to get "mmm"
Text.Start([#"Date - Copy"],3)
3.Select Date column-->Click "Add Column" tab -->Date-Year only
4. Add custom column:
=[mmm]&" "& Text.End( Text.From([Year]),2)
5. Remove unnecessary columns, below is the final table:
The whole M syntax:
let
Source = Sql.Database("WX-85154\MSSQLSERVER01", "Eyelyn Test"),
dbo_DateValue = Source{[Schema="dbo",Item="DateValue"]}[Data],
#"Duplicated Column" = Table.DuplicateColumn(dbo_DateValue, "Date", "Date - Copy"),
#"Changed Type" = Table.TransformColumnTypes(#"Duplicated Column",{{"Date - Copy", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "mmm", each Text.Start([#"Date - Copy"],3)),
#"Inserted Year" = Table.AddColumn(#"Added Custom", "Year", each Date.Year([Date]), Int64.Type),
#"Added Custom1" = Table.AddColumn(#"Inserted Year", "mmm yy", each [mmm]&" "& Text.End( Text.From([Year]),2)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Year", "Date - Copy", "mmm"})
in
#"Removed Columns"
Now you could use mmm yy column as X-axis:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Syndicate_Admin maybe add another duplicate date column, change the format to what you want, and use that on the x-axis.
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
I have added the new column and I have put another format but how do I enter it on the x axis without them coming out in days?
Excuse my inexperience.
Greetings
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
106 | |
98 | |
65 | |
54 |