Custom dates table Problem

monsoonnut

New Member
Joined
Jul 1, 2016
Messages
13
Hi

I am working on a forecast accuracy report that runs weekly - I have a custom dates table ('SCMWEEK') that contains weeks with WEEK_IK being the Key.


WEEK_IKWEEKYEARYYYYWW
83842015201504
83952015201505
84062015201506
84172015201507
84282015201508

<tbody>
</tbody>

This table is linked to my data table via the YYYWW column and I have created calculations for LW using the GFITW and all is working:

Accuracy Wk-1:=IF(HASONEVALUE(SCMWEEK[WEEK_IK]),CALCULATE([Accuracy],
ALL('SCMWEEK'),FILTER(ALL('SCMWEEK'),SCMWEEK[WEEK_IK]=VALUES(SCMWEEK[WEEK_IK])-1)),BLANK())

However, when I want to compare TY vs. LY I am running into problems due to the variable length of timeframes used, meaning I cannot just amend the -1 in the above formula to -52.

The model used means that when comparing with LY an extra week may need to be added or a week removed to keep the Yr on Yr comparisons aligned:


Duplicate weekWeek Removed
TY WeekLY WeekTY WeekLY Week
1111
2222
3333
4444
5456
6567
7678
8789
98910
1091011

<tbody>
</tbody>

I assume I will need another look-up table but I am not sure what format this would need to take or which DAX formulas are required to return the correct data.

Any help appreciated!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi,


not sure I understand your "variable length of timeframes used" as this make it not possible to know how to align the period.
What's not clear is how this can affect your LY but not TY?
Usually when referring to previous period logic, you need to know at least 1 section that remain the same (in your case could be week, but not sure why it's not the same) and you move across time by adjusting another component (year in this instance).
Alternatively , you could also add a column to SCMWEEK to include the previous period equivalent.

Again both suggestions might not be working if your not able to identify how to find the previous year matching period.

This would work in a normal situation:

Code:
=IF (
    HASONEVALUE ( SCMWEEK[WEEK_IK] ),
    CALCULATE (
        [Accuracy],
        FILTER (
            ALL ( SCMWEEK ),
            SCMWEEK[YEAR]
                = MAX ( SCMWEEK[YEAR] ) - 1
                && SCMWEEK[WEEK] <= MAX ( SCMWEEK[PREVIOUS YEAR WEEK] )
        )
    ),
    BLANK ()
)

Here's an excellent resource for Time patters: Time Patterns – DAX Patterns

Sharing your file would shed some light on your "variable length" and make it easier to understand your situation.

Eric

 
Upvote 0
Hi Eric

Thanks for the response.

After thinking about the problem I realised I am an idiot!

I was trying to create a dates table where I assigned last years weeks to this years weeks rather than assigning last years weeks to this years.

Once I cleared that up that error in my head (and model) all worked like a dream.

M
 
Upvote 0
Correction:

I was trying to create a dates table where I assigned this years weeks to last years weeks rather than assigning last years weeks to this years weeks
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top