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
nagoor
Helper III
Helper III

Percentage Deviations hour to hour

Dear Experts, 

 

I have an excel data for each hour sales against the products, I want to compare the sales deviations compared to last week on the same day and today. 

 

Ex: Today(14-11) with Thursday(07-11) 

 

Usually, I do it excel in the below way. 

 

1) Pivot the raw data. 

2) select the today and Thursday

3) Then copy and paste it in another sheet 

4) And then do the formula (Today-Thursday/Thursday)*100 

 

 

I have attached the sample file, could someone suggest the best possible way to do it in Power Bi. 

 

Thanks

Meeran

 

Sample file 

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

Hi @nagoor ,

Please try the following formula.

Percentage Deviations = 
var Today = CALCULATE(SUM('Table'[Total item sale]),FILTER('Table','Table'[Date] = TODAY()))
var Last_Week = CALCULATE(SUM('Table'[Total item sale]),FILTER('Table','Table'[Date] = TODAY()-7))
return
IF(Today = BLANK(),BLANK(),DIVIDE(Today- Last_Week,Last_Week))

2.PNG 

The formula above is a little different between what in my sample. Because there is no data which on 11/15/2019. You could reference the sample but use the formula above. Hope it will help you.

 

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
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

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @nagoor ,

Please try the following formula.

Percentage Deviations = 
var Today = CALCULATE(SUM('Table'[Total item sale]),FILTER('Table','Table'[Date] = TODAY()))
var Last_Week = CALCULATE(SUM('Table'[Total item sale]),FILTER('Table','Table'[Date] = TODAY()-7))
return
IF(Today = BLANK(),BLANK(),DIVIDE(Today- Last_Week,Last_Week))

2.PNG 

The formula above is a little different between what in my sample. Because there is no data which on 11/15/2019. You could reference the sample but use the formula above. Hope it will help you.

 

Best Regards,

Xue Ding

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

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

Hi @v-xuding-msft

 

Thanks a lot for your help, it really worked out. I have another doubt. 

Is that possible to select the date range dynamically, which means not only the selected -1 & -8 days if we want to compare the trend for -2 & -10 also by selecting in the date field if it gives the deviation percentage it would help us better? 

 

Thanks in advance, 

Meeran

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.