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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
pbiforum123
Post Patron
Post Patron

Help needed to get the required output using date functions..

Let say the input date for all the below dates is "Date(2019,10,30)"...

 

Following are the output that is required... Please help...

 

1. BeforeSales3Months --> date(2019,7,31)
2. SalesLast3Month --> date(2019,10,31)
3. SalesNext3Month --> date(2020,1,31)
4. SalesOlderThanThisMonth --> date(2019,9,30)
5. SalesThisMonth --> date(2019,10,31)
6. SalesNextMonth --> date(2019,11,30)

 

I need date functions which can get me the above output. I am also searching for the required date functions in google which can get me the above output.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@pbiforum123 

 

You may refer to the DAX below.

Measure =
VAR d =
    DATE ( 2019, 10, 30 )
VAR m = -3
RETURN
    DATE ( YEAR ( d ), MONTH ( d ) + m + 1, 1 ) - 1

 

Community Support Team _ Sam Zha
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
v-chuncz-msft
Community Support
Community Support

@pbiforum123 

 

You may refer to the DAX below.

Measure =
VAR d =
    DATE ( 2019, 10, 30 )
VAR m = -3
RETURN
    DATE ( YEAR ( d ), MONTH ( d ) + m + 1, 1 ) - 1

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tahreem24
Super User
Super User

Hi @pbiforum123 ,

 

There are DAX functions available which helps you to calculate these requirement. And you can also use Date Column as a slicer with Relative option.

 

1. BeforeSales3Months = CALCULATE(Sum(Table[Sales]),DATESADD(Table[DateCOlumn],-3,MONTH))
2. SalesLast3Month --> date(2019,10,31) ?? I am confused at this measure. What do you wanna display?
3. SalesNext3Month --> CALCULATE(Sum(Table[Sales]),DATESADD(Table[DateCOlumn],3,MONTH))
4. SalesOlderThanThisMonth --> CALCULATE(Sum(Table[Sales]),PREVOIUSMONTH(Table[DateColumn]))
5. SalesThisMonth --> CALCULATE(SUM(Table[Sales]),PARALLELPERIOD(Table[ColumnDate],0,MONTH))
6. SalesNextMonth --> CALCULATE(Sum(Table[Sales]),DATESADD(Table[DateCOlumn],1,MONTH))

 

 

Please give Thumps up for support and accept this as a solution if it helps you!

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Thanks a lot for your response...

 

Regarding the pt2, it has to get the End of the Month of Date(2019,10,30), which will be 2019,10,31

 

By the way I dont want to calculate Sales using these functions. 

 

I need the output in exactly the way I mentioned as I am passing these dates in the Date buckets in the matrix... Please refer below link for more understanding..

 

https://community.powerbi.com/t5/Desktop/Help-required-in-Switch-statement/m-p/864506/highlight/fals...

Hi @pbiforum123 ,

 

You can also use Relative Date slicer in order to see all those values and play around by changing its option. (Screen shot is attached)

Capture.JPG

Please give Thumps up for support and accept this as a solution if it helps you!

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

I need in this format only for the reasons mentioned above...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors