cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Calculating Last 3 Month Production

I need to calculate the Last 3 Months of Production using Dax.  I feel like the code below should be correct, but is missing something simple.  Can I use the word month, when using FiscalMonth Sales?  Are there any other metrics needed?  I also have access  to a Calendar Table which could work.

 

I attempted a solution but am getting a syntax error.  

 

3 month = CALCULATE(
	SUM(FactProductionTransactionDetail[Quantity]),
	DATESINPERIOD(DimDate[FiscalMonthNumber],DimDate[FiscalMonthNumber] = "201912",-3,month))
3 REPLIES 3
Highlighted
Helper III
Helper III

Re: Calculating Last 3 Month Production

I attempted a new solution using Calendarmonth instead of FiscalMonth, but got the same result.  The other thing I forgot to mention is that I want it to calculate using the selected period instead of an entered period.  For instance, instead of typing "6" below, I want it to calculate previous 3 months sales based on a filter or a month column if the view is in a table.

 

3 month = CALCULATE(
	SUM(FactProductionTransactionDetail[Quantity]),
	DATESINPERIOD(DimDate[CalendarMonthNumber],DimDate[CalendarMonthNumber] = "6",-3,month))
Highlighted
Community Support
Community Support

Re: Calculating Last 3 Month Production

@Buzz1126 ,

 

Please modify the measure using dax below and check if it can meet your requirement:

3 month =
CALCULATE (
    SUM ( FactProductionTransactionDetail[Quantity] ),
    DATESINPERIOD (
        DimDate[CalendarMonthNumber],
        DimDate[CalendarMonthNumber] = SELECTEDVALUE ( Table[Selection] ),
        -3,
        MONTH
    )
)

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Helper III
Helper III

Re: Calculating Last 3 Month Production

Can you  use SELECTEDVALUE in an Analysis Services connection?

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors