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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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