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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
sapirmarko
Helper I
Helper I

avg change in last 7 days for orders

Hi evryone,

I need help with the calculation:

I heve this measure:

unique_outlet_order_30d = CALCULATE([distinct orders],DATESBETWEEN('Date_Created_Date'[Date],LASTDATE('Date_Created_Date'[Date])-30, LASTDATE('Date_Created_Date'[Date])))
 
I need to calculate the change between today and yesterday for the last 7 days and to do avarge about the score
 
for example: 
 orders in last 30 dayschange
29/05/2023103
28/05/20237-1
27/05/202383
26/05/20235-4
25/05/202394
24/05/20235-1
23/05/202366
   
 avg1.4
 
 
there is a way to calculate it with a measure?
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@sapirmarko , Try like

 

Calculate(AVERAGEX(Values('Date'[Date]), [This Day] - [diff]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-7,DAY) )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

v-zhangti
Community Support
Community Support

Hi, @sapirmarko 

 

You can try the following methods.

Measure:

Change = 
Var _Previousdate=MAXX(FILTER(ALL('Table'),[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Var _Previousorder=CALCULATE(SUM('Table'[orders in last 30 days]),FILTER(ALL('Table'),[Date]=_Previousdate))
Var _Currentorder=SUM('Table'[orders in last 30 days])
Return
_Currentorder-_Previousorder
Result = IF(HASONEVALUE('Table'[Date]),[Change],AVERAGEX('Table',[Change]))

vzhangti_0-1685516272229.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Thanks! it's working great! 

v-zhangti
Community Support
Community Support

Hi, @sapirmarko 

 

You can try the following methods.

Measure:

Change = 
Var _Previousdate=MAXX(FILTER(ALL('Table'),[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Var _Previousorder=CALCULATE(SUM('Table'[orders in last 30 days]),FILTER(ALL('Table'),[Date]=_Previousdate))
Var _Currentorder=SUM('Table'[orders in last 30 days])
Return
_Currentorder-_Previousorder
Result = IF(HASONEVALUE('Table'[Date]),[Change],AVERAGEX('Table',[Change]))

vzhangti_0-1685516272229.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

@sapirmarko , Try like

 

Calculate(AVERAGEX(Values('Date'[Date]), [This Day] - [diff]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-7,DAY) )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.