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 in Power BI by Evanjalin
• 19,000 points

edited Mar 3 by Evanjalin 36 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 by anonymous
• 19,000 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,030 points
19,284 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,770 points
5,020 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 in Power BI by anonymous
• 19,000 points
43 views
0 votes
1 answer

How to customize the report for different users in power BI?

There are different ways to achieve this. 1. ...READ MORE

answered Oct 30, 2019 in Power BI by Cherukuri
• 33,030 points
4,356 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 2,650 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,350 points
1,262 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
19,151 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,350 points
37,864 views
0 votes
1 answer
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 4 days ago in Power BI by anonymous
• 19,000 points
40 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