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
RaffiKouzoudj
Helper III
Helper III

Get Last 6 months

Hi all,

 

I have a date filter at the level of the page (on the filter pane), and I want to get the last 6 months of the date chosen from the filter. That is if I choose 31/03/2021 then I need to have the date Oct, Nov, Dec 2020 and then Jan, Feb and March 2021. I am using the below query however it is not working all the time.

 

Your help is really appreciated. thank you.

 

Last6months = V_ticketing_PBI[DateReceive]>=EDATE(EOMONTH(maxx(allselected('V_ticketing_PBI'), V_ticketing_PBI[DateReceive]),0),-6)
1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @RaffiKouzoudj ,

 

First change the slicer setting to "Before". 

image.png

Then create the following formula:

Measure = 
var maxdate = 
    MAXX(
        ALLSELECTED(V_ticketing_PBI),
        V_ticketing_PBI[DateReceive]
    )
return 
    CALCULATE(
        SUM(V_ticketing_PBI[value]),
        FILTER(
            V_ticketing_PBI,
            V_ticketing_PBI[DateReceive] > EDATE(EOMONTH(maxdate,0),-6)
        )
    )

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @RaffiKouzoudj ,

 

First change the slicer setting to "Before". 

image.png

Then create the following formula:

Measure = 
var maxdate = 
    MAXX(
        ALLSELECTED(V_ticketing_PBI),
        V_ticketing_PBI[DateReceive]
    )
return 
    CALCULATE(
        SUM(V_ticketing_PBI[value]),
        FILTER(
            V_ticketing_PBI,
            V_ticketing_PBI[DateReceive] > EDATE(EOMONTH(maxdate,0),-6)
        )
    )

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@RaffiKouzoudj , if you need only one row in time or 6 month rolling you can try a measure like this example

 

Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-6,MONTH))

 

But if you want to have a trend of six months, you need an independent date table too. refer my video

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

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.