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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

WORKING WITH DATES

Hi Everybody,

 

I have a challenge for you guys. In my dataset I have a column with dates.

 

Then, in my report I need to create a kpi about last 3 months sales (excluding current month). I was thinking to create a new column/measure (feel free to sugest which one suits better this matter) where I do a formula like

 

IF(AND(MONTH(Date)=MONTH(TODAY())-1;YEAR(Date)=YEAR(TODAY());Sales;0))

 

Then doing the same for MONTH(TODAY())-2 and -3, and then summing the all three columns values. However Power BI Returns me some errors.

 

Any suggestions?

 

Thanks in advance.

 

AS

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

There could be other smart approaches too, but just to answer your question,

 

1. Create a new column with this formula :

 

last_Month=IF( AND(MONTH(Sheet1[Date])=MONTH(TODAY())-1,YEAR(Sheet1[Date])=YEAR(TODAY())),Sheet1[Sales],0)

 

2. Create a new measure with this formula:

 

Sales_Lastmonth= SUM( Sheet1[last_Month]

 

This will fetch you last month sales. You can do similarly for other months too.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi

There could be other smart approaches too, but just to answer your question,

 

1. Create a new column with this formula :

 

last_Month=IF( AND(MONTH(Sheet1[Date])=MONTH(TODAY())-1,YEAR(Sheet1[Date])=YEAR(TODAY())),Sheet1[Sales],0)

 

2. Create a new measure with this formula:

 

Sales_Lastmonth= SUM( Sheet1[last_Month]

 

This will fetch you last month sales. You can do similarly for other months too.

Anonymous
Not applicable

That works perfeclty! However i'm curious about the other smart ways you can get this value. Any ideas?

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.