How to Calculate Total Sales for the Last 3 Months Dynamically in DAX

0 votes
How to Calculate Total Sales for the Last 3 Months Dynamically in DAX?
In Power BI, I need to create a DAX measure that calculates the total sales for the last three months relative to the latest available data, regardless of user slicer selections. What is the best way to construct this measure using functions like DATESINPERIOD or CALCULATE to ensure dynamic date filtering?
Mar 3, 2025 in Power BI by Evanjalin
• 36,180 points

edited Mar 3, 2025 by Evanjalin 805 views

1 answer to this question.

0 votes

To dynamically calculate total sales for the last 3 months, ignoring user slicers, use this DAX measure:

TotalSalesLast3Months =
CALCULATE(
    SUM(Sales[OrderAmount]),
    DATESINPERIOD(
        Sales[OrderDate],
        MAX(Sales[OrderDate]),
        -3,
        MONTH
    )
)

Explanation:

  • DATESINPERIOD selects a 3-month window ending at the latest available date in the dataset.
  • CALCULATE applies this filtered period to sum the OrderAmount.
  • This measure dynamically updates based on new data but ignores slicers unless modified with ALLSELECTED().

answered Mar 3, 2025 by anonymous
• 36,180 points

Related Questions In Power BI

0 votes
1 answer

How to calculate cumulative Total and % in DAX?

Hi, If your table is ready with percentage ...READ MORE

answered Mar 18, 2019 in Power BI by Cherukuri
• 33,050 points
20,039 views
0 votes
1 answer

How to measure in DAX to calculate YTD for chosen month only for Power BI?

If you use the date column from FactTable, ...READ MORE

answered Dec 22, 2020 in Power BI by Gitika
• 65,730 points
5,731 views
0 votes
1 answer

How to Calculate Dynamic Regional Sales Percentage in DAX?

To compute the percentage of total sales ...READ MORE

answered Mar 3, 2025 in Power BI by anonymous
• 36,180 points
431 views
0 votes
1 answer

How do I dynamically calculate the first and last transaction date for each customer?

Calculation of the first transaction date and ...READ MORE

answered Apr 1, 2025 in Power BI by anonymous
• 36,180 points
747 views
+3 votes
2 answers

Combine tables in Power BI

You can also achieve this using a ...READ MORE

answered Oct 5, 2018 in Power BI by lina
• 8,220 points

edited Oct 11, 2018 by Kalgi 3,409 views
0 votes
1 answer

Power Bi Dax Table

You need to wrap the numbers in ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 52,340 points
1,790 views
0 votes
2 answers

Power BI Dax Multiple IF AND Statements

HI I have Column Patient 12 13 14 15 18 IN Patient=12, 13 Out ...READ MORE

answered May 23, 2019 in Power BI by VNK
20,095 views
0 votes
1 answer

Distinct count filtered by condition using Power BI Dax

Try this, it should work: DistinctCountActiveMonths = CALCULATE( ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 52,340 points
38,967 views
0 votes
1 answer

I want to calculate the distinct count of active customers but only for the last three completed months—how can I do this in DAX?

To calculate the distinct count of active ...READ MORE

answered Mar 10, 2025 in Power BI by anonymous
• 36,180 points
755 views
0 votes
1 answer

I need to calculate a running total but reset it at the start of each new quarter—how can I achieve this in DAX?

To calculate a running total that resets ...READ MORE

answered Mar 7, 2025 in Power BI by anonymous
• 36,180 points
1,015 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