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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
THENNA_41
Post Partisan
Post Partisan

Rolling Demand calcualtion based on the select Weeknum

Month                          Weeknum                     DMDTotal         Inv
September 2024            WK352024                      200            4545
September 2024            WK362024                      200            4100
September 2024            WK372024                     200             4300
September 2024           WK382024                      200              4600
September 2024           WK392024                      200              2100
September 2024           WK402024                      200              2200
October 2024                WK412024                     250               2600
October 2024                 WK422024                    250               3600
October 2024              WK432024                      250              5600
October 2024                WK442024                    250              6600
November2024              WK452024                   200             1233
November2024                WK462024                 200             1233

I have the data till december 2025
Now if I am select any weeknum from selected weeknum to 12 weeks rolling DMDTOTal and selected Inv total and divided by 60 days (its static)

for example suppose I am select WK352024 then rolling 12 weeks to WK462024 total 2600
(WK352024,wk362024,wk372024,wk382024,wk392024,wk402024,wk412024,wk422024,wk432024,wk442024,wk452024,wk462024)

and selected week inv 4545

60 days static

then want calculation = 2600/(4545/60)

using dax ?

1 ACCEPTED SOLUTION

hello @THENNA_41 

 

is this what you are looking for?

 

Irwan_0-1725342372528.png

Irwan_1-1725342390086.png

 

if yes, then:

1. create a calculated column for indexing. This indexing used for identifying when the Weeknum order (since week number is in middle character).

Index =
RANKX(
    'Table',
    'Table'[Weeknum],
    ,ASC,
    Dense
)

Irwan_2-1725342507361.png

 

2. create measures with following DAX.

Selected INV = 
var _Inv = SELECTEDVALUE('Table'[Inv])
Return
IF(
    HASONEVALUE('Table'[Weeknum]),
    _Inv,
    ""
)
Sum DMDTotal =
var _MaxIndex = SELECTEDVALUE('Table'[Index])+12
var _MinIndex = SELECTEDVALUE('Table'[Index])
Return
IF(
    HASONEVALUE('Table'[Weeknum]),
    SUMX(
        FILTER(
            ALL('Table'),
            'Table'[Index]<=_MaxIndex&&'Table'[Index]>=_MinIndex
        ),
        'Table'[DMDTotal]
    )
)
Calculation = 
DIVIDE(
    'Table'[Sum DMDTotal],DIVIDE(
        'Table'[Selected INV],
        60
    )
)
 
Hope this will help.
Thank you.

View solution in original post

4 REPLIES 4
Rupak_bi
Post Prodigy
Post Prodigy

Hi @THENNA_41 ,

 

Here is your solution:

Rupak_bi_1-1725283638071.png

Rolling Demand =

Var Week_Num = WEEKNUM(max('Table'[Month]))

Var week_12 = Week_Num+12

Var inv= max('Table'[Inv])
Var dmd = sumx(filter(all('Table'),WEEKNUM('Table'[Month])>=Week_Num&&WEEKNUM('Table'[Month])<week_12),'Table'[DMDTotal])

return
dmd/(inv/60)





Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

@Rupak_bi  its not return a correct value .. Weeknum  its  text format 

OK, Then Please modify the DAX as below

 

Rolling Demand =

 

Var Week_Num = value(MID(max('Table'[Weeknum]),3,2))

Var week_12 = Week_Num+12 Var inv= max('Table'[Inv])

Var dmd = sumx(filter(all('Table'),value(MID(max('Table'[Weeknum]),3,2))>=Week_Num&&value(MID(max('Table'[Weeknum]),3,2))<week_12),'Table'[DMDTotal])

 

return

dmd/(inv/60)

 

Please let me know if it works. However, it is good to use date as index because when year will change, this formula will not work properly. So I suggest to use the previous DAX only and modify your Month column as date with 7 days interval for sustainable output.



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

hello @THENNA_41 

 

is this what you are looking for?

 

Irwan_0-1725342372528.png

Irwan_1-1725342390086.png

 

if yes, then:

1. create a calculated column for indexing. This indexing used for identifying when the Weeknum order (since week number is in middle character).

Index =
RANKX(
    'Table',
    'Table'[Weeknum],
    ,ASC,
    Dense
)

Irwan_2-1725342507361.png

 

2. create measures with following DAX.

Selected INV = 
var _Inv = SELECTEDVALUE('Table'[Inv])
Return
IF(
    HASONEVALUE('Table'[Weeknum]),
    _Inv,
    ""
)
Sum DMDTotal =
var _MaxIndex = SELECTEDVALUE('Table'[Index])+12
var _MinIndex = SELECTEDVALUE('Table'[Index])
Return
IF(
    HASONEVALUE('Table'[Weeknum]),
    SUMX(
        FILTER(
            ALL('Table'),
            'Table'[Index]<=_MaxIndex&&'Table'[Index]>=_MinIndex
        ),
        'Table'[DMDTotal]
    )
)
Calculation = 
DIVIDE(
    'Table'[Sum DMDTotal],DIVIDE(
        'Table'[Selected INV],
        60
    )
)
 
Hope this will help.
Thank you.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.