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
bilalkhokar73
Helper IV
Helper IV

Date selection before 3 ,after 3 month

When I select a date range then i want to get the sales that What was befpre 3 month sales and after 3 month sales

Let say i selected 01June to 30 June 2021 then i need to shwo in my stacked area graph that on this selected date range from date table 

So sin chart i will put month , i need sales when i select this date it shoudl give me march,april,may i.e (before 3 month) and june,july,august after 3 month like thiss

So on selected date range i need sales of that range beofre 3 month  and thsi 3 month, 

7 REPLIES 7
v-yalanwu-msft
Community Support
Community Support

Hi, @bilalkhokar73 ;

Is the above answer helpful to you? If so, Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yalanwu-msft
Community Support
Community Support

Hi, @bilalkhokar73 ;

You could create a date table as a slicer, and then create a measure.

Rolling =
VAR _per =
    EOMONTH ( MIN ( 'slicer'[Date] ), -3 )
VAR _last =
    EOMONTH ( MAX ( 'slicer'[Date] ), 3 )
RETURN
    CALCULATE (
        SUM ( [value] ),
        FILTER (
            ALL ( 'Table' ),
            [Date] <= MAX ( [Date] )
                && [Date] >= DATE ( YEAR ( _per ), MONTH ( _per ), DAY ( MIN ( 'slicer'[Date] ) ) )
                && [Date]<= DATE ( YEAR ( _last ), MONTH ( _last ), DAY ( MAX ( 'slicer'[Date] ) ) ))

The final output is shown below:

vyalanwumsft_0-1629097221377.png

Best Regards,
Community Support Team_ Yalan Wu
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

@bilalkhokar73 , if you wanted data rolled at jun then

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD("Date"[Date ],eomonth(MAX("Date"[Date ]),-3)+1,6,MONTH))

 

 

If you want a trend then you need to use an independent date table

Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

I have date table, In my sales table I donto have data of april and may , then also it is givign me data fo april,may and dat comign wrong
I need when i select June then last 3 monht and next 3 month sales june will be included in next 3 month
Let say I seleted date from 15th june to 30 th june then data will come from 15th march to 15 april,15april to 15 may like this ....

bilalkhokar73_0-1628834695281.png@amitchandak 

Desired result format

bilalkhokar73_1-1628834928751.png

 

 

@bilalkhokar73 ,remove eomonth , try like

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD("Date"[Date ],MAXX("Date",dateadd("Date"[Date],-3,month)),6,MONTH))

 

 

no still same @amitchandak  when i select juen then only june coming 

bilalkhokar73_0-1628838911632.png

 

@amitchandak 
I have tried this but when i select july then it givess me only july sales
I need when july select then july last 3 month and next 3 month like that 

#Datesvprjt =

var a=IF(ISFILTERED(Sales[Odate]),CALCULATE(sum(Sales[Amt]),FILTER(date,date[Date]>=MAX(Sales[Ordt])-90 && date[Date]<=MAX(Sales[Ordt])+90)),0)
var b=CALCULATE(sum(Sales[Amt]),ALL(Sales[Amt]))
return IF(ISFILTERED(Sales[Ordt]),a,b)

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.