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
donglanmao1996
Frequent Visitor

Average order value by # of order (AOV 1st order, 2nd order, 3rd order, …)

I want to calculate the average order value by # of order (AOV 1st order, 2nd order, 3rd order, …). Which DAX can I use to turn the table above to the table below? Thank you!!!

donglanmao1996_0-1672940576989.png

 

2 ACCEPTED SOLUTIONS
v-cgao-msft
Community Support
Community Support

Hi @donglanmao1996 ,

 

Please create two new calculated columns:

AOG = 
VAR _no_of_order = CALCULATE(COUNT('Table'[Index]),'Table'[Index] <= EARLIER('Table'[Index]),ALLEXCEPT('Table','Table'[User_ID]))
VAR _revenue = CALCULATE(SUM('Table'[Order_Value]),'Table'[Index] <= EARLIER('Table'[Index]),ALLEXCEPT('Table','Table'[User_ID]))
VAR _aog = DIVIDE(_revenue,_no_of_order)
RETURN
_aog
#_of_order = RANKX(FILTER('Table','Table'[User_ID]=EARLIER('Table'[User_ID])),'Table'[AOV],,DESC,Dense)

vcgaomsft_0-1672983437478.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

Thank you! Can you please have a look on my screenshot below. Is there a bug with sorting of index column and how can I fix it?

donglanmao1996_0-1672999984212.png

 

View solution in original post

3 REPLIES 3
v-cgao-msft
Community Support
Community Support

Hi @donglanmao1996 ,

 

Please create two new calculated columns:

AOG = 
VAR _no_of_order = CALCULATE(COUNT('Table'[Index]),'Table'[Index] <= EARLIER('Table'[Index]),ALLEXCEPT('Table','Table'[User_ID]))
VAR _revenue = CALCULATE(SUM('Table'[Order_Value]),'Table'[Index] <= EARLIER('Table'[Index]),ALLEXCEPT('Table','Table'[User_ID]))
VAR _aog = DIVIDE(_revenue,_no_of_order)
RETURN
_aog
#_of_order = RANKX(FILTER('Table','Table'[User_ID]=EARLIER('Table'[User_ID])),'Table'[AOV],,DESC,Dense)

vcgaomsft_0-1672983437478.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thank you! Can you please have a look on my screenshot below. Is there a bug with sorting of index column and how can I fix it?

donglanmao1996_0-1672999984212.png

 

Hi @donglanmao1996 ,

 

It seems that the type of the [Index] column is now text, please change its type to whole number.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

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.