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
Reroo
Frequent Visitor

Dynamic Date & Site/Location Reference in Like For Like Calculations

Hi, everyone.

 

I have been having trouble with performing like for like calculations.

Specifically, the task is to produce like for like calculation table where I would have comparison of two periods with the corresponding deviation. In creating my model I mostly used the technic described here. I tried to ask a question there but my question keeps getting marked as spam and as a result it wouldn't get posted. 

 

So basically I am calculating sales for locations that were open across all selected timeframes. A location is defined as open if it has been open for the whole year (12 months). Furthermore, I would also like to calculate sales of previous year so that I could use it to reference in my variance measure. 

 

I have my calendar, accounts and locations (accounting units) table. 

For dynamic calculation of sales per location I created a measure that would look for locations that were open across all timeframes selected and then use them as filter in sales calculation. 

 

My goal is to create a measure for previous period. Ideally, it would be different depending on the years chosen in slicer since I would like to be able to do a dynamic comparison between a current year with the previous periods. However, my priority is to be able to calculate the previous year value, but would really appreciate if anyone had any suggestions about the best way of this kind of calculation. However, I haven't been able to achieve this and have been struggling for over a month now.

 

The sample data and model design could be found here

 

I am quite open to any feedback and would really appreciate any help here.

1 ACCEPTED SOLUTION
Reroo
Frequent Visitor

Hey, 

 

I figured it out. I just integrated in my measure the minimum date that I then used in time filter for calendar year:

 

<div>

 

Measure =
VAR MinimumDate = CALCULATE(MIN('Calendar'[Year]),ALLSELECTED('Calendar'[Year]))
VAR Result = CALCULATE (
    [LFL EBITDA Actual],
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = ( MinimumDate )
            && 'Calendar'[Month] IN VALUES ( 'Calendar'[Month] )
    )
)
RETURN
    Result

 

 

</div>

 

Best regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Reroo ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
CALCULATE (
    [LFL EBITDA Actual],
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = ( SELECTEDVALUE ( 'Calendar'[Year] ) - 1 )
            && 'Calendar'[Month] IN VALUES ( 'Calendar'[Month] )
    )
)

vpollymsft_0-1652942108237.png

If I have misunderstood your meaning, please provide more details with your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

Hey, thanks a lot. This does it.

 

I would also like to be able to choose the previous period and not be limited to only one period back. So say when I want to compare 2022 with 2019, I would like to select these two in my year slicer the measure would then dynamically calculate the sales for these two periods, that is sales for locations that were open between these two periods, whereas current year measure would refer to 2022 and previous year measure refer to 2019 while picking only the locations that were open only in these two years. 

 

Do you have an idea how one could achieve that? 

 

Thanks and best regards,

Reroo
Frequent Visitor

Hey, 

 

I figured it out. I just integrated in my measure the minimum date that I then used in time filter for calendar year:

 

<div>

 

Measure =
VAR MinimumDate = CALCULATE(MIN('Calendar'[Year]),ALLSELECTED('Calendar'[Year]))
VAR Result = CALCULATE (
    [LFL EBITDA Actual],
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = ( MinimumDate )
            && 'Calendar'[Month] IN VALUES ( 'Calendar'[Month] )
    )
)
RETURN
    Result

 

 

</div>

 

Best regards

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!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

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.