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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.