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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Previous Period Difference and Percent Change

 

 

Period Hours Change Calculation.PNG

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

You can try to create  calculated columns as follows

 

Pre_Sche Chh Booked Hrs = 
VAR Pre_date =
    CALCULATE (
        MAX ( 'dim Date'[Date] ),
        'dim Date',
        'dim Date'[Date] < EARLIER ( 'dim Date'[Date] )
    )
RETURN
    CALCULATE (
        SUM ( 'dim Date'[Sche Chh Booked Hrs] ),
        'dim Date',
        'dim Date'[Date] = Pre_date
    )
diff = 
IF (
    ISBLANK ( 'dim Date'[Pre_Sche Chh Booked Hrs] ),
    BLANK (),
    'dim Date'[Sche Chh Booked Hrs] - 'dim Date'[Pre_Sche Chh Booked Hrs]
)
Growth % = 
IF (
    ISBLANK ( 'dim Date'[diff] ),
    BLANK (),
    'dim Date'[diff] / 'dim Date'[Pre_Sche Chh Booked Hrs]
)

 

The result will show as below:

22.png
Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason
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

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

You can try to create  calculated columns as follows

 

Pre_Sche Chh Booked Hrs = 
VAR Pre_date =
    CALCULATE (
        MAX ( 'dim Date'[Date] ),
        'dim Date',
        'dim Date'[Date] < EARLIER ( 'dim Date'[Date] )
    )
RETURN
    CALCULATE (
        SUM ( 'dim Date'[Sche Chh Booked Hrs] ),
        'dim Date',
        'dim Date'[Date] = Pre_date
    )
diff = 
IF (
    ISBLANK ( 'dim Date'[Pre_Sche Chh Booked Hrs] ),
    BLANK (),
    'dim Date'[Sche Chh Booked Hrs] - 'dim Date'[Pre_Sche Chh Booked Hrs]
)
Growth % = 
IF (
    ISBLANK ( 'dim Date'[diff] ),
    BLANK (),
    'dim Date'[diff] / 'dim Date'[Pre_Sche Chh Booked Hrs]
)

 

The result will show as below:

22.png
Please check my sample file for more details.

 

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

AllisonKennedy
Super User
Super User

@Anonymous  This can be done if you add another column to your table for YearPeriod - it should be unique so will look something like:

2020-03-1 for March period 1

2020-04-2 for April period 2

Then you can create a DAX Measure and use a variable to get the previous period.

 

It will be similar to the below: 

PrevPeriod Hours =

VAR _MaxPeriod = MAX(DimDate[YearPeriod])

VAR _prevPeriod = MAXX(FILTER(DimDate, DimDate[YearPeriod] <_MaxPeriod), DimDate[YearPeriod])

RETURN

CALCULATE([hours], DimDate[YearPeriod] = _prevPeriod)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

We ended up created our previous measures and incorporated the previous period in our data model, which helped immensely.

 

Actual Chg Hrs Last Period =
var LastPeriod = max('dim FiscalFinancialPeriod'[PreviousPeriod])
var ReturnThis =
CALCULATE(SUM('fact ActualHours'[hours])
, FILTER(ALL('fact ActualHours'), 'fact ActualHours'[ChargeType]="Chargeable")
, FILTER(ALL('dim FiscalFinancialPeriod'), 'dim FiscalFinancialPeriod'[FiscalFinancialPeriod]=LastPeriod)
)
return (ReturnThis)
 
Actual Chg Hrs Last Week =
var CurrentWeek = LASTDATE('dim Date'[FirstOfWeek])
var LastWeek = DATEADD(CurrentWeek, -7, DAY)

var ReturnThis =

CALCULATE(SUM('fact ActualHours'[hours])
, FILTER(ALL('fact ActualHours'),'fact ActualHours'[ChargeType] = "Chargeable")
, FILTER(ALL('dim Date'), 'dim Date'[FirstOfWeek]=LastWeek) )

return (ReturnThis)
 
We then calculated the percent change from the previous/current period measure we had. This resulted in the percent change that we were looking for.
 
Thanks for your solution! It helped!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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