cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShipraJain
Helper I
Helper I

Previous month sales

Hi All,

 

Previously thanks for the help,

I have calculated previous month sum of values with using formula as below (Which is working fine ) :

Previous Month  = CALCULATE(SUM(data[data_A]),DATEADD(Dates[Date_2022],-1,MONTH) )
 
But now I want to calculate same previous month value but in this formula I have to use Filter-condition and I am getting blank values please find the below used formula :
 
Previous month = CALCULATE(SUM(TableA[A]),FILTER(TableA,TableA[Value] = "EW"),DATEADD(Dates[Date_2022],-1,MONTH))
Please help me on this.
 
Thanks
Shipra
 
1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @ShipraJain,

 

You may try this Measure.

Previous_month = CALCULATE(SUM(TableA[A]),DATEADD(Dates[Date_2022],-1,MONTH),FILTER(TableA,TableA[Value]="EW"))

 

The result will look like this.

vcazhengmsft_0-1655184368658.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

4 REPLIES 4
v-cazheng-msft
Community Support
Community Support

Hi @ShipraJain,

 

You may try this Measure.

Previous_month = CALCULATE(SUM(TableA[A]),DATEADD(Dates[Date_2022],-1,MONTH),FILTER(TableA,TableA[Value]="EW"))

 

The result will look like this.

vcazhengmsft_0-1655184368658.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Samarth_18
Super User
Super User

Hi @ShipraJain ,

Please try this:-

Previous month =
CALCULATE (
    SUM ( TableA[A] ),
    FILTER ( TableA, TableA[Value] = "EW" ),
    FILTER ( ALL ( Dates ), DATEADD ( Dates[Date_2022], -1, MONTH ) )
)

BR,

Samarth


If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin


Hi @Samarth_18 ,

 

Thanks for the reply.

I am getting incorrect output using this formula. Kindly help if any other formula available.

 

Thanks

Shipra

@ShipraJain , Its bit difficult to answer without data and expected output. You could try this as well:-

Previous month =
CALCULATE (
    SUM ( TableA[A] ),
    FILTER ( TableA, TableA[Value] = "EW" ),
    FILTER (  Dates , DATEADD ( Dates[Date_2022], -1, MONTH ) )
)

or please share the sample data in text format(not a screenshot) with expected output.


If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin


Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors