8 Easy Steps to Isolate Weekdays in Power BI Query

Power BI Query Window with Weekday Function Applied

Within the huge and complicated realm of knowledge evaluation, one job that continuously arises is the necessity to isolate weekdays from a dataset. This seemingly simple operation can current challenges when working with massive and complicated datasets, particularly when utilizing Energy BI Question. Nevertheless, armed with the fitting data and methods, extracting weekdays out of your knowledge generally is a piece of cake. Let’s delve into the world of Energy BI Question and unravel the secrets and techniques of weekday isolation, empowering you to unlock the total potential of your knowledge.

To embark on this knowledge exploration, we’ll start by understanding the anatomy of a date worth in Energy BI Question. Every date worth consists of three key parts: 12 months, month, and day. The day part is what we’re after, because it represents the precise day of the week. Energy BI Question supplies a myriad of features that permit us to govern and extract completely different elements of a date worth. Amongst these features is the “Date.Day” perform, which, as its identify suggests, returns the day of the week for a given date.

With the “Date.Day” perform at our disposal, we are able to now embark on the duty of isolating weekdays. To illustrate we’ve a desk named “Gross sales” that comprises a column named “Date” with date values. To extract the weekdays from this column, we are able to create a brand new column utilizing the next system: Weekday = Date.Day(Gross sales[Date]). This system applies the “Date.Day” perform to every date worth within the “Date” column, successfully extracting the corresponding weekdays. The result’s a brand new column named “Weekday” that comprises the weekdays for every row within the “Gross sales” desk. Now, you’ve gotten the facility to research knowledge, determine developments, and make knowledgeable selections based mostly on remoted weekday data.

$title$

Load the Information

Step one in isolating weekdays in Energy BI Question is to load the information into the question editor. This may be executed by utilizing the “Get Information” choice from the Residence tab in Energy BI Desktop.

As soon as the information is loaded, it is going to seem within the question editor. The question editor is a robust software that permits you to rework and clear your knowledge earlier than loading it into Energy BI.

To isolate weekdays, you’ll need to make use of the “Add Column” choice from the Remodel tab within the question editor. It will add a brand new column to your knowledge desk that comprises the weekday for every row.

The next desk reveals the steps for loading the information into the question editor:

Step Description
1 Open Energy BI Desktop.
2 Click on on the “Get Information” choice from the Residence tab.
3 Choose the information supply that you simply need to use.
4 Click on on the “Load” button.

Create a Customized Column for Day of Week

To create a customized column for the day of the week, observe these steps:

  1. Within the Energy BI Question Editor, choose the desk that comprises the date column you need to use.
  2. Click on the “Add Column” tab, then click on the “Customized Column” button.
  3. Within the “Customized Column” dialog field, enter a reputation for the brand new column within the “Identify” area.
  4. Within the “Method” area, enter the next system:
  5. “`
    = Date.DayOfWeek([Date Column])
    “`

  6. Click on “OK” to create the brand new column.

The brand new column will show the day of the week for every date within the unique date column. For instance, if the date column comprises the worth “2023-03-08”, the brand new column will show “Wednesday”.

You should use the next desk to map the numeric values returned by the Date.DayOfWeek perform to the corresponding days of the week:

Numeric Worth Day of Week
1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday

Filter by Weekday

To filter knowledge by weekday in Energy BI Question, you should utilize the Date.DayOfWeek() perform. This perform takes a date worth as enter and returns a quantity from 1 to 7, the place 1 represents Sunday and seven represents Saturday.

You should use the Date.DayOfWeek() perform to create a filter expression that features or excludes particular weekdays. For instance, the next filter expression would come with solely rows the place the date is a Monday, Tuesday, or Wednesday:

“`
= Date.DayOfWeek([Date]) >= 2 && Date.DayOfWeek([Date]) <= 4
“`

It’s also possible to use the Date.DayOfWeek() perform to create a calculated column that reveals the weekday for every row. This may be helpful for visualizing knowledge by weekday or for performing calculations based mostly on the weekday.

The next desk summarizes the doable values for the Date.DayOfWeek() perform:

Worth Weekday
1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday

Use the Date Desk

The Date Desk is a robust software in Energy BI that can be utilized to unravel a wide range of knowledge manipulation duties. One frequent job is to isolate the weekdays from a set of dates.

To do that, you should utilize the next steps:

  1. Create a brand new question and choose the Date Desk from the record of obtainable tables.
  2. Add a brand new column to the question and identify it “Weekday”.
  3. Within the Method bar, enter the next system:
    “`
    = DATEVALUE(WEEKDAY([Date]))
    “`
    This system will return the weekday quantity for every date within the Date Desk.

  4. Filter the question to solely embrace the rows the place the Weekday column is the same as the specified weekday. For instance, to solely embrace the rows for Monday, you’ll use the next filter:
    “`
    = [Weekday] = 1
    “`

    Make use of the Weekday Perform

    The Weekday perform in Energy BI Question is indispensable for isolating weekdays from dates. This perform assigns a numerical worth to every day of the week, starting from 1 (Sunday) to 7 (Saturday).

    To make use of the Weekday perform, merely specify the date worth as an argument. As an example, the system = Weekday(Date) will return the corresponding numerical worth for the desired date. You may then make use of this worth to filter or group knowledge based mostly on weekdays.

    Day of the Week Numerical Worth
    Sunday 1
    Monday 2
    Tuesday 3
    Wednesday 4
    Thursday 5
    Friday 6
    Saturday 7

    The Weekday perform supplies versatility in manipulating date knowledge. It allows you to extract particular days, carry out calculations, or create visible representations based mostly on weekdays, enhancing the insights you derive out of your knowledge.

    Leverage the Calendar Hierarchy

    The Calendar Hierarchy is a built-in desk in Energy BI that gives a hierarchical construction for dates. It consists of columns for 12 months, quarter, month, week, and day of week.

    To isolate weekdays utilizing the Calendar Hierarchy, you may observe these steps:

    1. Add the Calendar Hierarchy to Your Mannequin

    Go to the Energy BI Desktop ribbon and click on on the “Modeling” tab. Within the “Desk” group, click on on the “New Desk” button.

    2. Choose the Calendar Hierarchy

    Within the “New Desk” dialog field, choose the “Calendar Hierarchy” choice.

    3. Create a Calculated Column for Weekday

    Click on on the “Add Column” button within the Energy BI Desktop ribbon and choose “Customized Column”.

    Within the system bar, enter the next system:

    “`
    = FORMAT([Date], “dddd”)
    “`

    It will create a brand new column referred to as “Weekday” that comprises the day of the week for every date within the Calendar Hierarchy.

    4. Filter the Desk by Weekday

    To isolate weekdays, you may filter the Calendar Hierarchy desk by the Weekday column. Choose the “Filter” icon within the “Residence” tab.

    5. Choose the Weekdays

    Within the “Filter” pane, choose the “Weekday” column and select the weekdays you need to embrace in your evaluation.

    6. Use the Filtered Desk in Your Evaluation

    After getting filtered the Calendar Hierarchy desk, you should utilize it in your evaluation to give attention to knowledge associated to particular weekdays. For instance, you may create a bar chart to point out gross sales by weekday or a line chart to trace income over time on weekdays.

    Weekday Variety of Gross sales
    Monday 100
    Tuesday 120
    Wednesday 130
    Thursday 140
    Friday 150

    Make the most of the Group By Operation

    The Group By operation in Energy BI Question is a robust software that permits you to group rows in a desk based mostly on a number of columns. This can be utilized to isolate weekdays from a date column by grouping the rows by the day of the week.

    To make use of the Group By operation, choose the date column within the Question Editor. Then, click on on the “Remodel” tab and choose “Group By”. Within the Group By dialog field, choose the “Day of Week” column from the “By” drop-down record. It will group the rows within the desk by the day of the week.

    As soon as the rows have been grouped, you should utilize the “Summarize” tab to create a brand new column that comprises the variety of rows in every group. To do that, click on on the “Summarize” tab and choose “Depend” from the “Combination” drop-down record. It will create a brand new column referred to as “Depend of Rows” that comprises the variety of rows in every group.

    Lastly, you should utilize the “Filter” tab to filter the desk to solely present the rows that correspond to the weekdays. To do that, click on on the “Filter” tab and choose “Is Better Than or Equal To” from the “Comparability” drop-down record. Then, enter the worth “1” within the “Worth” field. It will filter the desk to solely present the rows which have a rely of rows larger than or equal to 1.

    The next desk summarizes the steps for isolating weekdays utilizing the Group By operation:

    | Step | Motion |
    |—|—|
    | 1 | Choose the date column within the Question Editor. |
    | 2 | Click on on the “Remodel” tab and choose “Group By”. |
    | 3 | Within the Group By dialog field, choose the “Day of Week” column from the “By” drop-down record. |
    | 4 | Click on on the “Summarize” tab and choose “Depend” from the “Combination” drop-down record. |
    | 5 | Click on on the “Filter” tab and choose “Is Better Than or Equal To” from the “Comparability” drop-down record. |
    | 6 | Enter the worth “1” within the “Worth” field. |

    Apply the Conditional Columns

    To use the conditional columns, observe these steps:

    1. Choose the Date column.
    2. Click on the "Add Column" button.
    3. Choose "Conditional Column" from the dropdown menu.
    4. Within the "Identify" area, enter a reputation for the brand new column.
    5. Within the "Expression" area, enter the next system:
    = IF(WEEKDAY([Date]) = 1, "Monday", IF(WEEKDAY([Date]) = 2, "Tuesday", IF(WEEKDAY([Date]) = 3, "Wednesday", IF(WEEKDAY([Date]) = 4, "Thursday", IF(WEEKDAY([Date]) = 5, "Friday", IF(WEEKDAY([Date]) = 6, "Saturday", "Sunday")))))))
    
    1. Click on the "OK" button.

    A brand new column shall be added to your desk with the weekday for every date.

    Instance

    The next desk reveals an instance of find out how to isolate weekdays utilizing conditional columns:

    Date Weekday
    2023-03-06 Monday
    2023-03-07 Tuesday
    2023-03-08 Wednesday
    2023-03-09 Thursday
    2023-03-10 Friday
    2023-03-11 Saturday
    2023-03-12 Sunday

    Implement the SWITCH Perform

    The SWITCH perform evaluates a sequence of expressions and returns the results of the primary expression that matches the desired enter worth. On this case, we are able to use the SWITCH perform to isolate weekdays from dates by evaluating the day of the week to a sequence of values.

    The syntax of the SWITCH perform is as follows:

    “`
    SWITCH(, , , , , …, )
    “`

    The place:

    * is the worth to be evaluated.
    * , , …, are the values to check the expression to.
    * , , …, are the outcomes to return if the expression matches the corresponding worth.
    * is the consequence to return if the expression doesn’t match any of the values.

    To isolate weekdays utilizing the SWITCH perform, we are able to use the next expression:

    “`
    SWITCH(DAY(), 1, “Sunday”, 2, “Monday”, 3, “Tuesday”, 4, “Wednesday”, 5, “Thursday”, 6, “Friday”, 7, “Saturday”)
    “`

    This expression will consider the day of the week for the desired date and return the corresponding weekday identify as a textual content worth.

    The next desk supplies an instance of how the SWITCH perform can be utilized to isolate weekdays:

    Date Day of the Week Outcome
    2023-03-08 Wednesday Wednesday
    2023-03-09 Thursday Thursday
    2023-03-10 Friday Friday

    Make use of the DAX Expression

    The DAX expression is a robust software that may be utilized to isolate weekdays in your Energy BI question. This expression leverages the WEEKDAY perform, which returns an integer representing the day of the week for a given date. By using this perform, you may extract the day of the week for every date in your dataset after which use this data to filter your question to incorporate solely the weekdays.

    10. Illustrating the DAX Expression

    To reveal find out how to isolate weekdays utilizing the DAX expression, take into account the next instance:

    Assume you’ve gotten a desk named “Gross sales” with the next columns:

    | Column | Information Sort |
    |—|—|
    | Date | Date |
    | Gross sales Quantity | Decimal |

    To isolate the weekdays from this desk, you may create a calculated column utilizing the next DAX expression:

    “`
    Weekdays = WEEKDAY(Gross sales[Date], 2)
    “`

    This expression makes use of the WEEKDAY perform to extract the day of the week for every date within the “Date” column. The second parameter of the WEEKDAY perform, “2”, signifies that the week ought to begin on Monday. Due to this fact, the Weekdays column will return the next values:

    Date Weekdays
    2023-03-06 2
    2023-03-07 3
    2023-03-08 4
    2023-03-09 5
    2023-03-10 6
    2023-03-11 7
    2023-03-12 1

    By creating the Weekdays column, you’ve gotten efficiently remoted the weekdays in your Energy BI question. Now you can use this column to filter your question to incorporate solely the weekdays.

    How To Isolate Weekdays Energy Bi Question

    To isolate weekdays in Energy BI Question, you should utilize the next steps:

    1. Load the information into Energy BI Desktop.
    2. Choose the column that comprises the date values.
    3. Click on on the “Add Column” tab within the ribbon.
    4. Choose “Date” from the drop-down menu.
    5. Choose “Week Day” from the drop-down menu.
    6. A brand new column shall be added to the desk that comprises the weekday values.

    You should use the weekday values to filter the information or to create visualizations that present the information by weekday.

    Individuals Additionally Ask

    The way to filter knowledge by weekday in Energy BI?

    To filter knowledge by weekday in Energy BI, you should utilize the next steps:

    1. Load the information into Energy BI Desktop.
    2. Choose the column that comprises the date values.
    3. Click on on the “Filter” icon within the ribbon.
    4. Choose “Week Day” from the drop-down menu.
    5. Choose the weekdays that you simply need to filter by.
    6. Click on on the “OK” button.

    The way to create a visualization that reveals the information by weekday in Energy BI?

    To create a visualization that reveals the information by weekday in Energy BI, you should utilize the next steps:

    1. Load the information into Energy BI Desktop.
    2. Choose the column that comprises the date values.
    3. Click on on the “Visualizations” tab within the ribbon.
    4. Choose the kind of visualization that you simply need to create.
    5. Drag and drop the date column onto the “Axis” area.
    6. Drag and drop the worth column onto the “Values” area.