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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
FOXYBARK
Helper III
Helper III

Percent change using hours

HI. 

I need help  perfoming a percent change using hours in a day. This will ultimately go in a line graph. Below is a snip of my dataset and commands. It's the previous value I can't get to work. I only want the distinct count of access numbers for the previous hour so I plot on a line graph. 

 

FOXYBARK_0-1656424629200.png

 

FOXYBARK_1-1656424837338.png

 

 

% Change = VAR CurrentValue = [cntAccessNumbers]
VAR PreviousValue = CALCULATE([cntAccessNumbers], Bdge1[BADGE_SCAN_TS]-1)
RETURN
DIVIDE(CurrentValue -  PreviousValue,
PreviousValue)

 

 Any advice is appreciated. 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @FOXYBARK ,

I created some data:

vyangliumsft_0-1656658372546.png

Here are the steps you can follow:

1. Create measure.

Measure_cntAccessNumbers = MAX('Table'[cntAccessNumbers])
Measure =
var _cvurrent=
SUMX(
    FILTER(ALL('Table'),
    YEAR('Table'[BADGE_SCAN_TS])=YEAR(MAX('Table'[BADGE_SCAN_TS]))&&
    MONTH('Table'[BADGE_SCAN_TS])=MONTH(MAX('Table'[BADGE_SCAN_TS]))&&
    DAY('Table'[BADGE_SCAN_TS])=DAY(MAX('Table'[BADGE_SCAN_TS]))&&
    HOUR('Table'[BADGE_SCAN_TS])=HOUR(MAX('Table'[BADGE_SCAN_TS]))),[Measure_cntAccessNumbers])
var _PreviousValue=
SUMX(
    FILTER(ALL('Table'),
    YEAR('Table'[BADGE_SCAN_TS])=YEAR(MAX('Table'[BADGE_SCAN_TS]))&&
    MONTH('Table'[BADGE_SCAN_TS])=MONTH(MAX('Table'[BADGE_SCAN_TS]))&&
    DAY('Table'[BADGE_SCAN_TS])=DAY(MAX('Table'[BADGE_SCAN_TS]))&&
    HOUR('Table'[BADGE_SCAN_TS])=HOUR(MAX('Table'[BADGE_SCAN_TS]))-1),[Measure_cntAccessNumbers])
return
DIVIDE(
    _cvurrent - _PreviousValue ,
    _PreviousValue)

2. Result:

vyangliumsft_1-1656658372548.png

There is one more thing to note: if your results are all 0, it may be that you have not set the % format, click your Measure -- Measure tools -- %

vyangliumsft_2-1656658372549.png

 

Best Regards,

Liu Yang

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
Anonymous
Not applicable

Hi  @FOXYBARK ,

I created some data:

vyangliumsft_0-1656658372546.png

Here are the steps you can follow:

1. Create measure.

Measure_cntAccessNumbers = MAX('Table'[cntAccessNumbers])
Measure =
var _cvurrent=
SUMX(
    FILTER(ALL('Table'),
    YEAR('Table'[BADGE_SCAN_TS])=YEAR(MAX('Table'[BADGE_SCAN_TS]))&&
    MONTH('Table'[BADGE_SCAN_TS])=MONTH(MAX('Table'[BADGE_SCAN_TS]))&&
    DAY('Table'[BADGE_SCAN_TS])=DAY(MAX('Table'[BADGE_SCAN_TS]))&&
    HOUR('Table'[BADGE_SCAN_TS])=HOUR(MAX('Table'[BADGE_SCAN_TS]))),[Measure_cntAccessNumbers])
var _PreviousValue=
SUMX(
    FILTER(ALL('Table'),
    YEAR('Table'[BADGE_SCAN_TS])=YEAR(MAX('Table'[BADGE_SCAN_TS]))&&
    MONTH('Table'[BADGE_SCAN_TS])=MONTH(MAX('Table'[BADGE_SCAN_TS]))&&
    DAY('Table'[BADGE_SCAN_TS])=DAY(MAX('Table'[BADGE_SCAN_TS]))&&
    HOUR('Table'[BADGE_SCAN_TS])=HOUR(MAX('Table'[BADGE_SCAN_TS]))-1),[Measure_cntAccessNumbers])
return
DIVIDE(
    _cvurrent - _PreviousValue ,
    _PreviousValue)

2. Result:

vyangliumsft_1-1656658372548.png

There is one more thing to note: if your results are all 0, it may be that you have not set the % format, click your Measure -- Measure tools -- %

vyangliumsft_2-1656658372549.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@FOXYBARK , Create an hour table and join it with the hour(Number format) of your table

 

then you can have measures like

 

This hour= CALCULATE(sum('Table'[Qty]), FILTER(ALL('hour'),'Date'[hour]=max('Date'[hour])))
Last hour= CALCULATE(sum('Table'[Qty]), FILTER(ALL('hour'),'Date'[hour]=max('Date'[hour])-1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Would my hour table only have the hour or should it have other columns as well? Such as date?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors