How do I create a rolling time window in Power BI visuals such as the past 7 or 30 days

0 votes
How do I create a rolling time window in Power BI visuals, such as the past 7 or 30 days?

 I'm working on a Power BI report that needs to display data from a rolling time window, such as the past 7 or 30 days. I'm struggling to implement this dynamically, ensuring that the visuals update based on the latest date selections without needing to manually adjust the filters.

What’s the best way to create a rolling time window in Power BI visuals, such as showing the past 7 or 30 days, and how can I ensure that it updates automatically based on the current date?
Nov 14, 2024 in Power BI by Evanjalin
• 19,000 points
137 views

2 answers to this question.

0 votes

To introduce a rolling time window in Power BI that dynamically updates the visuals to represent data from the past 7 days or 30 days, there are DAX measures and date filter options that can be altered depending on the date today. Here is how to do it stepwise.

Create a Date Table: If your existing data model doesn't have a date table, you will have to create an appropriate date table to accommodate all time-related calculations. Ensure that it covers every possible date range without leaving out any gaps and comprises at least a column for day, month, and year. Such a date table is important for applying time range filters in Power BI.

Add a DAX measure for the Rolling Window: To visualize how figures change over the past 7 or 30 days, create another measure on two dimensions that calculate windows.

For example, if one wants to get a rolling 7-day measure, he can write the DAX expression as follows.

Rolling 7 Days Sales = 

CALCULATE(

 SUM('Sales'[Amount]),

 DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -7, DAY) 

)

This metric finds the total sales for the last seven days, calculated from the maximum date in the current context. In the case of a rolling window of thirty days, you would modify the -7 to -30 to include every day for thirty days.

Making Use of Relative Date Filtering: Power BI also comes with an option that makes it easier to rotate and adjust the time periods by including relative date filters in the visual. Within the Filters pane, click on the Date field and select the “Relative date filtering” option. At this point, one can indicate “is in the last” and fill in the number of days (say 7 or 30) in order to restrict their visuals from showing any data older than a week or a month, respectively. This filter will refresh itself whenever new information is inputted or when the day of the data entry progresses, enabling the visual to be up to date with no need for manual intervention.

In addition to facilitating the automatic updates to the visuals within the reports over a run period, the date table and the DAX measures complemented by the relative date filtering make the Power BI report more engaging for purposes of continuous evaluation.

answered Nov 15, 2024 by pooja
• 16,780 points
0 votes
  • Create a Date Table: Include a calculated column for a rolling period, e.g., RollingDays = IF(Date >= TODAY() - 30, "Last 30 Days", "Other").

  • Use Relative Date Slicer: Add a Relative Date Slicer to filter visuals for the past 7, 30, or other periods.

  • Dynamic Measures: Use DAX, e.g.,

RollingSum = CALCULATE(SUM(Table[Value]), DATESINPERIOD(DateTable[Date], TODAY(), -30, DAY))

The visuals will auto-update with current date data

answered Jan 23 by pooja
• 16,780 points

Related Questions In Power BI

0 votes
2 answers

How do I create custom tooltips that display different information based on the visual or data point in Power BI?

Custom tooltips: Create a report page dedicated to detailed information and link that to visuals. For ...READ MORE

answered Jan 23 in Power BI by anonymous
• 16,780 points
161 views
0 votes
1 answer

How do you troubleshoot inconsistent visuals or slicer behavior across different pages in a Power BI report?

In Power BI troubleshooting inconsistent visuals or ...READ MORE

answered Dec 18, 2024 in Power BI by anonymous
• 2,780 points

edited 6 days ago 153 views
0 votes
1 answer

How do I troubleshoot Power BI visuals that are showing as blank after applying a specific filter?

It is commonly noticed that blank visuals ...READ MORE

answered Dec 30, 2024 in Power BI by Vani
• 3,440 points

edited 6 days ago 183 views
0 votes
1 answer

How to export Power Queries from One Workbook to Another with VBA?

Try solving it using the Workbook. Query ...READ MORE

answered Oct 22, 2018 in Power BI by Annie97
• 2,160 points
6,969 views
0 votes
1 answer

Excel Power Query: Using List.MatchAny on a column value

try this. let TableA = ...READ MORE

answered Oct 22, 2018 in Power BI by Annie97
• 2,160 points
4,477 views
0 votes
1 answer

How can I search for multiple strings?

A simple solution is this: List.ContainsAny(Text.SplitAny("This is a test ...READ MORE

answered Oct 24, 2018 in Power BI by Upasana
• 160 points
4,847 views
0 votes
1 answer

Power Query Web request results in “CR must be followed by LF” Error

What I think is, it might look ...READ MORE

answered Oct 29, 2018 in Power BI by Shubham
• 13,490 points
1,996 views
+1 vote
1 answer
0 votes
1 answer

How do I calculate a rolling average or cumulative total in Power BI without performance issues?

To enable rolling averages or cumulating summations ...READ MORE

answered Dec 30, 2024 in Power BI by Anu
• 2,780 points

edited 6 days ago 142 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP