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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

anmolmalviya05

Displaying Sales Data for the Past 30, 60, and 90 Days in Power BI

Have you ever needed to view sales performance over different time periods like the past 30, 60, or 90 days? In this blog, I’ll walk you through how to create a dynamic slicer-based solution that allows you to switch between these periods and analyze your sales data accordingly.

 

Let’s break it down step by step:

 

🔹 Step 1: Create a Period Selection Table

First, go to the Home ribbon and click on Enter Data.

Manually create a simple table with one column like this:

 

Last N Days

30 Days

60 Days

90 Days

 

Name this table something like TimePeriod.

 

This table will serve as the slicer to filter the sales for the selected time frame.

 

🔹 Step 2: Add the Slicer to Your Report

Drag the Last N Days column from the TimePeriod table onto the report and add it as a Slicer.

This allows users to toggle between 30, 60, or 90 days.

 

🔹 Step 3: Create the Dynamic Measure for Sales

Now, it’s time to create a DAX measure that dynamically calculates the sales based on the slicer selection.

 

Last N Days Sales =

VAR days_30 =

CALCULATE(

SUM(Orders[Sales]),

FILTER('Date Table', 'Date Table'[Date] >= TODAY() - 29 && 'Date Table'[Date] <= TODAY())

)

 

VAR days_60 =

CALCULATE(

SUM(Orders[Sales]),

FILTER('Date Table', 'Date Table'[Date] >= TODAY() - 59 && 'Date Table'[Date] <= TODAY())

)

 

VAR days_90 =

CALCULATE(

SUM(Orders[Sales]),

FILTER('Date Table', 'Date Table'[Date] >= TODAY() - 89 && 'Date Table'[Date] <= TODAY())

)

 

RETURN

SWITCH(

MAX(TimePeriod[Last N Days]),

"30 Days", days_30,

"60 Days", days_60,

"90 Days", days_90

)

Make sure you have a proper Date Table marked as a date table in your model.

 

🔹 Step 4: Display the Measure

Drag your new measure into a Card visual (or any other visual you prefer), and link it to the slicer.

 

As you select “30 Days,” “60 Days,” or “90 Days” from the slicer, the measure updates dynamically to show the total sales for that range.

 

Final Result

With this setup, you now have a powerful and interactive report that can display sales data based on the user’s selected time frame — giving better flexibility and insights to decision-makers.

 

Hope you found this tutorial helpful!

Let me know in the comments if you’d like to explore more time-based calculations in Power BI.

 

Best regards

Anmol Malviya

Sr. Data Analyst | Addend Analytics