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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
prabhuss
Helper I
Helper I

PREVIOUSMONTH in not working if Time select is Jan 2018

Hi All,

Wishing you happy new year. Starting this new year, we observed one of our 

dashboard is not working. This dashboard is suppored to compare between Current month Sales vs Previous Months Sales. As of Jan 2018, Current month is going to be Jan 2018 and Previous month is going to be Dec 2017.

 

we are using following formula to calculate previous month sales

PrevMonthSale = CALCULATE(SUM(CustomerInvoice[PayableAmount]),  PREVIOUSMONTH(CustomerInvoice[InvoiceDate])).

 

Any help to resolve this is very well appriciated as we are using this dashboard activily 

 

Regards,

Prabhu Srivastava

 

 

1 ACCEPTED SOLUTION

@prabhuss,

Create the measure using one of the DAX below,  then use Year field and Month field of Datetable to create slicers.

PrevMonthSale = CALCULATE(SUM(CutsomerInvoice[PayableAmount]),  PREVIOUSMONTH(DateTable[Date]))
PrevMonthSale1 = 
CALCULATE (
    SUM ( CutsomerInvoice[PayableAmount] ),
    DATEADD ( DateTable[Date], -1, MONTH )
)

1.JPG

2.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

@prabhuss

 

Try this one

 

PrevMonthSale =
CALCULATE (
    SUM ( CustomerInvoice[PayableAmount] ),
    DATEADD ( CustomerInvoice[InvoiceDate], -1, MONTH )
)

Regards
Zubair

Please try my custom visuals

I had tried earlier, and did not work for me. Even , PrevMonth = CALCULATE(SUM(CustomerInvoice[PayableAmount]),  PARALLELPERIOD(CustomerInvoice[InvoiceDate],-1,MONTH)) did not work.

 

 

@prabhuss

 

Your formula will also work fine. Just add a Calendar Table using CalendarAuto() function. Then create a relationship between CalendarTable and Invoice Date.

 

PrevMonthSale = CALCULATE(SUM(CustomerInvoice[PayableAmount]),  PREVIOUSMONTH(CustomerInvoice[InvoiceDate]))


Regards
Zubair

Please try my custom visuals

CalendarAuto()  does not work for directquery. The trick i played that I  created SQL Table  called DateTable and

Then created a relationship between DateTable and Invoice Date.

 

@prabhuss,

Create the measure using one of the DAX below,  then use Year field and Month field of Datetable to create slicers.

PrevMonthSale = CALCULATE(SUM(CutsomerInvoice[PayableAmount]),  PREVIOUSMONTH(DateTable[Date]))
PrevMonthSale1 = 
CALCULATE (
    SUM ( CutsomerInvoice[PayableAmount] ),
    DATEADD ( DateTable[Date], -1, MONTH )
)

1.JPG

2.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.