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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ydundar
Frequent Visitor

getting data of 3 months before selected month

endate = DATE(YEAR(TODAY()), SELECTEDVALUE(Months[Month], MONTH(TODAY())),1)
3MonthsSalesAverage = CALCULATE(SUM(factSalesAmount[CIRO])/3, FILTER(factSalesAmount, factSalesAmount[date] >= DATEADD([endate],-3,MONTH) && factSalesAmount[date] < [endate]))

 

Hi,

I need to get 3 months sales average data before selected month in power bi. Selected month is not coming from date table. I use it as parameter to calculate [endate]. But DATEADD function doesn't accept date part as measure. I will be appreciate for any help or idea. Than

3 REPLIES 3
amitchandak
Super User
Super User

Create a new end date three months back

 

endate = DATE(YEAR(datediff(TODAY(),-3,month)), SELECTEDVALUE(Months[Month], MONTH(datediff(TODAY(),-3,month))),1)

Do needed changed.

 

You need to get a date three months before and do it.

Hi,

Actually I need to get 3 data which  dates have to be between first day of selected month and 3 months before selected month (which can be in previous year). 

The datediff works on continuous data. This means it will work selected values. Now covert selected value into a date and subtract three months. post that takes a min of it.  That is the start date. After you created date, it will not allow you to use date diff.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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