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
PKGARG
Helper I
Helper I

Compare SamePeriod Sale

I have two table with Sale 2015-2016 and 2016-2017. In these table i have data of sale locationWise with datewise.

Suppose Loc XJ Open 12-06-2015 now i need

1. Compare Sameperiod Sale,   for example, XJ Sale 12-06-2015 to 31-03-2016 is 11005880 And 12-06-2016 to 31-03-2017 is 12180408 then Result for New Column (Compare) is 10.67%

 

1 ACCEPTED SOLUTION

@PKGARG

 

Hi,

 

In your situation, we aggregate data with two aspects: Date and Location and the data are separate in two tables. So we need two new tables if you didn’t have them.

 

DateTable =
CALENDAR ( DATE ( 2015, 1, 1 ), DATE ( 2017, 12, 31 ) ) 

 

Locations =
DISTINCT (
    UNION (
        SUMMARIZE (
            '2015-2016',
            '2015-2016'[Loc_id],
            '2015-2016'[Loc_State],
            '2015-2016'[Loc_City]
        ),
        SUMMARIZE (
            '2016-2017',
            '2016-2017'[Loc_id],
            '2016-2017'[Loc_State],
            '2016-2017'[Loc_City]
        )
    )
)

Then create relationship with the new table. The details are in the picture (upper).

Create three measures with these formula.

 

Sales2015-2016 =
CALCULATE (
    SUM ( '2015-2016'[Sale] ),
    SAMEPERIODLASTYEAR ( 'DateTable'[Date] )
)
Sales2016-2017 =
SUM ( '2016-2017'[Sale] )
Sales Compare =
( [Sales2016-2017] - [Sales2015-2016] )
/ [Sales2015-2016]

Create report. Actually, your two reports are one due to we can control the period with the date slicer. Please have a try.

Compare SamePeriod Sale 2.jpg

 

Compare SamePeriod Sale 3.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

Community Support Team _ Dale
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

15 REPLIES 15
v-jiascu-msft
Employee
Employee

@PKGARG

 

Hi,

 

You can attach files with OneDrive or Dropbox and paste URL here. Maybe you could review this sample first. @Greg_Deckler's SAMEPERIODLASTYEAR is a good idea.

First, create a date table to connect these two tables.

 

DateTable =
CALENDAR ( DATE ( 2015, 6, 1 ), DATE ( 2017, 4, 1 ) )

Second, establish relationship. (As showed in the picture.)

Third, Create measure.

 

Compare =
VAR LastSales =
    CALCULATE (
        SUM ( 'Sales2015-2016'[Sales1] ),
        SAMEPERIODLASTYEAR ( 'DateTable'[Date] )
    )
VAR CurrentSales =
    SUM ( 'Sales2016-2017'[Sales2] )
RETURN
    ABS ( LastSales - CurrentSales )
        / LastSales
 

We can create one more measure to check the result.

 

SalesInSamePeriodLastYear =
CALCULATE (
    SUM ( 'Sales2015-2016'[Sales1] ),
    SAMEPERIODLASTYEAR ( 'DateTable'[Date] )
)

Compare SamePeriod Sale .jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

 

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

PLEASE  CHECK MY DATA I HAVE LINKED MY DATA

 

https://1drv.ms/x/s!AqGdStzHrospaZSo2lTxFillv-k

I Need 2 Report Like This.

 

Report 1According to Financial Year    
      
Sum of Sale  Fin_Year  
Loc_idLoc_StateLoc_City2015-20162016-2017Sale Compare
11HARYANASONIPAT2850553 -100.00%
20DELHINEW DELHI23584820250894416.38%
26DELHINEW DELHI44596893613806-18.97%
37DELHINEW DELHI47860564512578-5.71%
46PUNJABAMRITSAR53598354969098-7.29%
48RAJASTHANJAIPUR1232926712246815-0.67%
51UPMEERUT1179587910915441-7.46%
56DELHINEW DELHI2798283325676666-8.24%
84DELHINEW DELHI200500627717901-61.51%
86PUNJABJALANDHAR610295861453440.69%
ACPUNJABAMRITSAR41210472879442-30.13%
ALJAMMU & KASHMIRJAMMU9480714104136209.84%
AQWEST BENGALKOLKATTA17794293184812583.86%
AVUNION TERRCHANDIGHAR (UT)5223224 -100.00%
Grand Total  155921231132661410-14.92%

Report 2According To Same Period In Financial Year    
      
Sum of Sale  Fin_Year  
Loc_idLoc_StateLoc_City2015-20162016-2017Sale Compare
11HARYANASONIPAT  #DIV/0!
20DELHINEW DELHI23584820250894416.38%
26DELHINEW DELHI44596893613806-18.97%
37DELHINEW DELHI47860564512578-5.71%
46PUNJABAMRITSAR53598354969098-7.29%
48RAJASTHANJAIPUR1232926712246815-0.67%
51UPMEERUT1179587910915441-7.46%
56DELHINEW DELHI2798283325676666-8.24%
84DELHINEW DELHI200500627717901-61.51%
86PUNJABJALANDHAR610295861453440.69%
ACPUNJABAMRITSAR41210472879442-30.13%
ALJAMMU & KASHMIRJAMMU9480714104136209.84%
AQWEST BENGALKOLKATTA17794293184812583.86%
AVUNION TERRCHANDIGHAR (UT)  #DIV/0!
Grand Total  147847454132661410-10.27%

also i need obtion i can view this report Monthwise, Financial Year Wise, Statewise

ANYONE CAN HELP ME

@PKGARG

 

Hi,

 

In your situation, we aggregate data with two aspects: Date and Location and the data are separate in two tables. So we need two new tables if you didn’t have them.

 

DateTable =
CALENDAR ( DATE ( 2015, 1, 1 ), DATE ( 2017, 12, 31 ) ) 

 

Locations =
DISTINCT (
    UNION (
        SUMMARIZE (
            '2015-2016',
            '2015-2016'[Loc_id],
            '2015-2016'[Loc_State],
            '2015-2016'[Loc_City]
        ),
        SUMMARIZE (
            '2016-2017',
            '2016-2017'[Loc_id],
            '2016-2017'[Loc_State],
            '2016-2017'[Loc_City]
        )
    )
)

Then create relationship with the new table. The details are in the picture (upper).

Create three measures with these formula.

 

Sales2015-2016 =
CALCULATE (
    SUM ( '2015-2016'[Sale] ),
    SAMEPERIODLASTYEAR ( 'DateTable'[Date] )
)
Sales2016-2017 =
SUM ( '2016-2017'[Sale] )
Sales Compare =
( [Sales2016-2017] - [Sales2015-2016] )
/ [Sales2015-2016]

Create report. Actually, your two reports are one due to we can control the period with the date slicer. Please have a try.

Compare SamePeriod Sale 2.jpg

 

Compare SamePeriod Sale 3.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

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

Ist of All Thanks,

Everything is may be ok, but i visualised data then Sales2015-2016 value not shown in Table and SalesCompare show infinity. When i changed by

Sales2015-2016=sum('2015-2016'[Sale]) its working and SalesCompare Result OK, Now Date Slicer is not Working. Pls see where i wrong....

Also i want to add Month Slicer to see on Month or Multiple Month Status

I try on data provided by me Its Working Sorry Dale, I am trying again where i am wrong. Again Thank You Very Much.

Hi,

 

It's my pleasure. I am so glad it helped. Maybe you need to make a few changes on the formula. 

 

 

Best Regards!

Dale

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

Hi

In My Same Report i want view it MonthWise according to financial year like firstly Apr,May,Jun,Jul.......

Also i need one more comparison for only same store.

Greg_Deckler
Super User
Super User

SAMEPERIODLASTYEAR?

https://msdn.microsoft.com/en-us/library/ee634972.aspx


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

how can i attach my data

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.