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
THENNA_41
Post Partisan
Post Partisan

Taking three Months Demand value form start week date

 I have the table name called Inventory  sheet . this table   sample data looks like below 

 

Version      Attribute      Value         Weekstartdate

 

pods         Demand         10            15  March  2021 

pods         DOI                20             14 November 2021 

pods         Demand         50            22 March 2021 

pods          DOI                40            21 November 2021 

pods         Demand         30            29 March 2021 

pods         Demand         50            05  April 2021 

pods         Demand         60            12  April 2021 

pods         DOI                10             28 November 2021 

pods         Demand         90            19 April 2021 

pods         Demand         10            26 April 2021 

 


I am trying to  get demand value from selected date to next three Months. i have  tired below measures

 

3 months total demand = CALCULATE([3 months total values],FILTER(Append1, Append1[Attributes]="Demand"))
 
 
3 months total values =
VAR LastDate_ = LASTDATE(Append1[Week Start date])
RETURN
    CALCULATE(
        SUM(Append1[Value]),
        DATESINPERIOD(Append1[Week Start date], LastDate_, 3, MONTH)
    )

 

But iam not getting correct value .  also attached  pbi  fILE ALSO  

Sample File : Sample Power bi  

 

Thanks in advance . 

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

Hi @THENNA_41 ,

1.Please to create a successive date table by “Append” table, and create a model

Calendar =
CALENDAR (
    FIRSTDATE ( 'Append'[Weekstartdate] ),
    LASTDATE ( 'Append'[Weekstartdate] )
)

vbinbinyumsft_0-1659519658075.png

vbinbinyumsft_2-1659519683371.png

 

2.Create two measure

Measure =
VAR cur_date =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Append'[Value] ),
        DATESINPERIOD ( 'Calendar'[Date], cur_date, 3, MONTH )
    )
Measure2 =
VAR cur_ste =
    SELECTEDVALUE ( 'Append'[Attribute] )
RETURN
    IF (
        cur_ste = "Demand",
        CALCULATE ( [Measure], 'Append'[Attribute] = "Demand" )
    )

Add a table visual:

vbinbinyumsft_3-1659519817546.png

Please refer attached .pbix file

 

Best regards,
Community Support Team_ Binbin Yu
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

4 REPLIES 4
v-binbinyu-msft
Community Support
Community Support

Hi @THENNA_41 ,

1.Please to create a successive date table by “Append” table, and create a model

Calendar =
CALENDAR (
    FIRSTDATE ( 'Append'[Weekstartdate] ),
    LASTDATE ( 'Append'[Weekstartdate] )
)

vbinbinyumsft_0-1659519658075.png

vbinbinyumsft_2-1659519683371.png

 

2.Create two measure

Measure =
VAR cur_date =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Append'[Value] ),
        DATESINPERIOD ( 'Calendar'[Date], cur_date, 3, MONTH )
    )
Measure2 =
VAR cur_ste =
    SELECTEDVALUE ( 'Append'[Attribute] )
RETURN
    IF (
        cur_ste = "Demand",
        CALCULATE ( [Measure], 'Append'[Attribute] = "Demand" )
    )

Add a table visual:

vbinbinyumsft_3-1659519817546.png

Please refer attached .pbix file

 

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

@v-binbinyu-msft  Thank  you so much its working  

THENNA_41
Post Partisan
Post Partisan

@amitchandak  sir  I have created Date table and also created new measure but values not getting correctly . please find the created measure below

 

Date = ADDCOLUMNS(CALENDAR(DATE(2020,1,1),DATE(2025,12,31)),"Dateasinteger",FORMAT([Date],"YYYYMMDD"),"YEAR",YEAR([Date]))
 
Rolling 3 = CALCULATE(sum(Append1[Value]),FILTER(Append1,Append1[Attributes]="Demand"),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),3,MONTH))
 
THENNA_41_0-1659416954522.png

 

amitchandak
Super User
Super User

@THENNA_41 , Please use date table and try

 

example

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

 

 

and why there is no demand filter in the second measure

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.

Top Solution Authors