Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
irnm8dn
Post Prodigy
Post Prodigy

Help with Dates and Date Formats and Proper Sorting

I currently use the following DAX statement to construct a date table:

 

Date =
ADDCOLUMNS (
CALENDAR (DATE(2000,1,1), DATE(2025,12,31)),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "Q" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" )

)

 

Additionally, I have added a column and DAX statement that allows me to have a Week Starting:

 

Week Starting = DATEADD(
'Date'[Date],
1-WEEKDAY('Date'[Date])
,DAY
)

 

Most of bases are covered, however I am also looking to represent days of the week on a axis with the ability to choose what days of the week I include on the axis.  

 

For instance, I may want to represent Monday through Friday in chronological date order; or I may want to show performance on a specific day of week in chronological order.  i.e. YTD performance on Monday's.  I would imagine the format would be something like Wednesday - 5/31/2017.

 

Questions:

  1. How do I add a column that will output a format like Wednesday - 5/31/2017?
  2. How do I select specific day(s) of the week to include on the axis?  
    1. i.e. Show me YTD performance for individual days but only include M,T,W,Th,Fr?
  3. How do I sort order to make sure that the days I represent are in chronological order?

Thanks in advance.

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @irnm8dn,

 

1. How do I add a column that will output a format like Wednesday - 5/31/2017?

 

You can combine the date column and DayOfWeek column with DAX below:

CONCATENATE('Date'[DayOfWeek],CONCATENATE(" - ",'Date'[Date]))

 

Or you can drag date column and DayOfWeek column to the X-axis then click the power-bi-drill-icon6.png button, see: August Power BI Desktop Update: Updated Drill experience.

 

q2.PNG

 


2.How do I select specific day(s) of the week to include on the axis?  1.i.e. Show me YTD performance for individual days but only include M,T,W,Th,Fr?

 

You can add DayOfWeek column into Visual Level Filters pane, then select those weekdays, M,T,W,Th,Fr.

 

 

3.How do I sort order to make sure that the days I represent are in chronological order?

 

As you place both date and DayOfWeek column in X-axis, the axis value will be sorted based on date. Also you can do the custom sort trick via the suggestion from v-haibl-msft: Custom Sorting in PowerBI?.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-qiuyu-msft
Community Support
Community Support

Hi @irnm8dn,

 

1. How do I add a column that will output a format like Wednesday - 5/31/2017?

 

You can combine the date column and DayOfWeek column with DAX below:

CONCATENATE('Date'[DayOfWeek],CONCATENATE(" - ",'Date'[Date]))

 

Or you can drag date column and DayOfWeek column to the X-axis then click the power-bi-drill-icon6.png button, see: August Power BI Desktop Update: Updated Drill experience.

 

q2.PNG

 


2.How do I select specific day(s) of the week to include on the axis?  1.i.e. Show me YTD performance for individual days but only include M,T,W,Th,Fr?

 

You can add DayOfWeek column into Visual Level Filters pane, then select those weekdays, M,T,W,Th,Fr.

 

 

3.How do I sort order to make sure that the days I represent are in chronological order?

 

As you place both date and DayOfWeek column in X-axis, the axis value will be sorted based on date. Also you can do the custom sort trick via the suggestion from v-haibl-msft: Custom Sorting in PowerBI?.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.