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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ZakyQadir
Frequent Visitor

Like for Like comparison

Hi,

I need your help on this issue, I need to find Like For Like (YoY comparison) between two full period. 

I have 3 table.
Sales Table
List Data Table
Calendar Table

I try to make comparison use sameperiodlast year but total are not equal with detail.
Like for like comparison only apply for full month, so if site open on 29/03/2023, it will start comparison on 01/04/2024 vs 01/04/2023.
Aplicable for every new site opened (Have several site) - Based on opening date


Current Measures i use i try to have another table for each stores and flag it with LFL but still no work.

_Sales TY LFL = CALCULATE(SUM(Sales[Sales]),FILTER(_StoreFlagLFL,_StoreFlagLFL[FlagLFL] = "LFL"))
_Sales LY LFL = CALCULATE([Total Sales]SAMEPERIODLASTYEAR(DateCalendar[Date]))

Thanks in advance for your help

 

Expected Result

SiteCodeDateTY Sales   LY Sales   % Growth   TY LFL Sales   LY LFL Sales   % LFL   
A00129/03/2024    20.00020.0000%   
A00130/03/202430.00030.0000%   
A00131/03/202415.00015.0000%   
A00101/04/202460.00040.00050%60.00040.00050%
A00102/04/202470.00050.00040%70.00050.00040%
A00103/04/202480.00060.00033%80.00060.00033%
  275.000215.00028%210.000150.00040%


List Data Table

SiteCode   OpenDate
A00129/03/2023
A00201/01/2022


Sales Table

SiteCode   DateSales
A00129/03/2023     20.000
A00130/03/202330.000
A00131/03/202315.000
A00101/04/202340.000
A00102/04/202350.000
A00103/04/202360.000
A00129/03/202420.000
A00130/03/202430.000
A00131/03/202415.000
A00101/04/202460.000
A00102/04/202470.000
A00103/04/202480.000
1 ACCEPTED SOLUTION

Hi,

Thanks for the solution @Dangar332  and @Greg_Deckler  offered, and i want to offer some more infotmation for user to refer to.

hello @ZakyQadir , you can refer to the following sample.

sample data is the same as you privded, i create a calendar table, and create relationship among tables.

vxinruzhumsft_0-1722912205544.png

Create the following measures.

Sales = SUM(Sales[Sales])
StartofMonth =
VAR a =
    MAX ( 'List Data'[OpenDate] )
VAR b =
    EOMONTH ( a, -1 ) + 1
VAR c =
    EOMONTH ( a, 0 ) + 1
RETURN
    IF ( [Sales] <> BLANK (), IF ( b = a, b, c ) )
TY LFL Sales =
VAR a =
    EDATE ( [StartofMonth], 12 )
VAR b =
    MAX ( 'Calendar'[Date] )
RETURN
    IF (
        OR (
            YEAR ( b ) = YEAR ( [StartofMonth] )
                && b >= [StartofMonth],
            YEAR ( b ) = YEAR ( a )
                && b >= a
        ),
        [Sales]
    )
LY LFL Sales = IF([TY LFL Sales]<>BLANK(),CALCULATE([Sales],SAMEPERIODLASTYEAR('Calendar'[Date])))
% LFL = DIVIDE([TY LFL Sales]-[LY LFL Sales],[LY LFL Sales])

Then put the measures to the visual.

vxinruzhumsft_1-1722912409398.png

Best Regards!

Yolo Zhu

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

Output

vxinruzhumsft_2-1722912419838.png

 

 

View solution in original post

6 REPLIES 6
Dangar332
Super User
Super User

Hi, @ZakyQadir 

I apologize, but I didn't understand your situation
can you elaborate what kind of output you get from above measures and where you stuck in there ?

Hi, 

I need result like expected result, currently im stuck like this. Last year sales calculated since opening date, bu i need full month as base so first few days not count as LFL basis.

Current situation

SiteCodeDateTY Sales   LY Sales   % Growth   TY LFL Sales  LY LFL Sales   % LFL
A00129/03/2024   20.00020.0000% 20.000 
A00130/03/202430.00030.0000% 30.000 
A00131/03/202415.00015.0000% 15.000 
A00101/04/202460.00040.00050%60.00040.00050%
A00102/04/202470.00050.00040%70.00050.00040%
A00103/04/202480.00060.00033%80.00060.00033%
  275.000215.00028%210.000215.000-2%
Greg_Deckler
Super User
Super User

@ZakyQadir First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Yes, but my knowledge not that good, i need your help about that, my measure wrong maybe there's another solution from the experts

Hi,

Thanks for the solution @Dangar332  and @Greg_Deckler  offered, and i want to offer some more infotmation for user to refer to.

hello @ZakyQadir , you can refer to the following sample.

sample data is the same as you privded, i create a calendar table, and create relationship among tables.

vxinruzhumsft_0-1722912205544.png

Create the following measures.

Sales = SUM(Sales[Sales])
StartofMonth =
VAR a =
    MAX ( 'List Data'[OpenDate] )
VAR b =
    EOMONTH ( a, -1 ) + 1
VAR c =
    EOMONTH ( a, 0 ) + 1
RETURN
    IF ( [Sales] <> BLANK (), IF ( b = a, b, c ) )
TY LFL Sales =
VAR a =
    EDATE ( [StartofMonth], 12 )
VAR b =
    MAX ( 'Calendar'[Date] )
RETURN
    IF (
        OR (
            YEAR ( b ) = YEAR ( [StartofMonth] )
                && b >= [StartofMonth],
            YEAR ( b ) = YEAR ( a )
                && b >= a
        ),
        [Sales]
    )
LY LFL Sales = IF([TY LFL Sales]<>BLANK(),CALCULATE([Sales],SAMEPERIODLASTYEAR('Calendar'[Date])))
% LFL = DIVIDE([TY LFL Sales]-[LY LFL Sales],[LY LFL Sales])

Then put the measures to the visual.

vxinruzhumsft_1-1722912409398.png

Best Regards!

Yolo Zhu

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

Output

vxinruzhumsft_2-1722912419838.png

 

 

It works really well, thanks a lot for your support...

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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