8 Easy Steps to Isolate Weekdays in Power BI Query

Power BI Query Window with Weekday Function Applied

Within the huge and sophisticated realm of knowledge evaluation, one job that incessantly arises is the necessity to isolate weekdays from a dataset. This seemingly easy operation can current challenges when working with massive and complicated datasets, particularly when utilizing Energy BI Question. Nonetheless, armed with the suitable information and methods, extracting weekdays out of your information is usually 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 information.

To embark on this information exploration, we’ll start by understanding the anatomy of a date worth in Energy BI Question. Every date worth consists of three key elements: 12 months, month, and day. The day element is what we’re after, because it represents the particular day of the week. Energy BI Question gives a myriad of features that enable us to control and extract totally different components of a date worth. Amongst these features is the “Date.Day” operate, which, as its title suggests, returns the day of the week for a given date.

With the “Date.Day” operate at our disposal, we will now embark on the duty of isolating weekdays. As an instance now we have a desk named “Gross sales” that comprises a column named “Date” with date values. To extract the weekdays from this column, we will create a brand new column utilizing the next components: Weekday = Date.Day(Gross sales[Date]). This components applies the “Date.Day” operate 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 got the facility to research information, establish developments, and make knowledgeable choices primarily based on remoted weekday data.

$title$

Load the Knowledge

Step one in isolating weekdays in Energy BI Question is to load the info into the question editor. This may be performed through the use of the “Get Knowledge” choice from the Dwelling tab in Energy BI Desktop.

As soon as the info is loaded, it’s going to seem within the question editor. The question editor is a robust software that means that you can remodel and clear your information earlier than loading it into Energy BI.

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

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

Step Description
1 Open Energy BI Desktop.
2 Click on on the “Get Knowledge” choice from the Dwelling tab.
3 Choose the info supply that you simply wish 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 wish 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 “Title” subject.
  4. Within the “Method” subject, enter the next components:
  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 authentic 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 operate 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 information by weekday in Energy BI Question, you should utilize the Date.DayOfWeek() operate. This operate 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() operate 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() operate to create a calculated column that reveals the weekday for every row. This may be helpful for visualizing information by weekday or for performing calculations primarily based on the weekday.

The next desk summarizes the attainable values for the Date.DayOfWeek() operate:

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 resolve quite a lot of information 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 listing of accessible tables.
  2. Add a brand new column to the question and title it “Weekday”.
  3. Within the Method bar, enter the next components:
    “`
    = DATEVALUE(WEEKDAY([Date]))
    “`
    This components 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 operate in Energy BI Question is indispensable for isolating weekdays from dates. This operate assigns a numerical worth to every day of the week, starting from 1 (Sunday) to 7 (Saturday).

    To make use of the Weekday operate, merely specify the date worth as an argument. As an example, the components = Weekday(Date) will return the corresponding numerical worth for the desired date. You possibly can then make use of this worth to filter or group information primarily based on weekdays.

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

    The Weekday operate gives versatility in manipulating date information. It lets you extract particular days, carry out calculations, or create visible representations primarily based on weekdays, enhancing the insights you derive out of your information.

    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 possibly can 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 components bar, enter the next components:

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

    This may 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 possibly can filter the Calendar Hierarchy desk by the Weekday column. Choose the “Filter” icon within the “Dwelling” tab.

    5. Choose the Weekdays

    Within the “Filter” pane, choose the “Weekday” column and select the weekdays you wish 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 concentrate on information associated to particular weekdays. For instance, you possibly can create a bar chart to indicate 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 means that you can group rows in a desk primarily based 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 listing. This may 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 listing. This may 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 Larger Than or Equal To” from the “Comparability” drop-down listing. Then, enter the worth “1” within the “Worth” field. This may filter the desk to solely present the rows which have a rely of rows better 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 listing. |
    | 4 | Click on on the “Summarize” tab and choose “Depend” from the “Combination” drop-down listing. |
    | 5 | Click on on the “Filter” tab and choose “Is Larger Than or Equal To” from the “Comparability” drop-down listing. |
    | 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 "Title" subject, enter a reputation for the brand new column.
    5. Within the "Expression" subject, enter the next components:
    = 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 might be added to your desk with the weekday for every date.

    Instance

    The next desk reveals an instance of how you can 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 operate evaluates a collection of expressions and returns the results of the primary expression that matches the desired enter worth. On this case, we will use the SWITCH operate to isolate weekdays from dates by evaluating the day of the week to a collection of values.

    The syntax of the SWITCH operate 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 end result to return if the expression doesn’t match any of the values.

    To isolate weekdays utilizing the SWITCH operate, we will 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 title as a textual content worth.

    The next desk gives an instance of how the SWITCH operate 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 operate, which returns an integer representing the day of the week for a given date. By using this operate, you possibly can 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 show how you can isolate weekdays utilizing the DAX expression, take into account the next instance:

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

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

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

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

    This expression makes use of the WEEKDAY operate to extract the day of the week for every date within the “Date” column. The second parameter of the WEEKDAY operate, “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 got 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 info 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 might be added to the desk that comprises the weekday values.

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

    Individuals Additionally Ask

    Learn how to filter information by weekday in Energy BI?

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

    1. Load the info 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 wish to filter by.
    6. Click on on the “OK” button.

    Learn how to create a visualization that reveals the info by weekday in Energy BI?

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

    1. Load the info 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 wish to create.
    5. Drag and drop the date column onto the “Axis” subject.
    6. Drag and drop the worth column onto the “Values” subject.