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! Request now

Reply
lt79_Pax
Helper II
Helper II

Sequences of events order number iteration error

Dear Power BI Forum,

I am reviewing DAX Chapter 16 Advanced Calculations in DAX in the Numbering sequences of events section and the formula for the Order Position is not functioning. There is a problem with the Sales [Order Number] variable CurrentOrderNumber. A single value for column 'Order Number' in  the table 'Sales' cannot be determined.  This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.  I know this filed needs to be set to an iterator however I do not know which one.  If anyone can assist with this I would greatly appreciate it.

OrderPosition =

VAR CurrentOrderNumber = Sales[Order Number]

VAR Position =

CALCULATE (

DISTINCTCOUNT ( Sales[Order Number] ),

Sales[Order Number] <= CurrentOrderNumber,

ALLEXCEPT (

Sales,

Sales[CustomerKey]

)

)

RETURN

Position

 

Thank you.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@lt79_Pax , current row context can be taken from min/max

This is approch for measure. In case column we can use earlier

OrderPosition =

VAR CurrentOrderNumber = max(Sales[Order Number])

VAR Position =

CALCULATE (

DISTINCTCOUNT ( Sales[Order Number] ),

Sales[Order Number] <= CurrentOrderNumber,

ALLEXCEPT (

Sales,

Sales[CustomerKey]

)

)

RETURN

Position

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@lt79_Pax , current row context can be taken from min/max

This is approch for measure. In case column we can use earlier

OrderPosition =

VAR CurrentOrderNumber = max(Sales[Order Number])

VAR Position =

CALCULATE (

DISTINCTCOUNT ( Sales[Order Number] ),

Sales[Order Number] <= CurrentOrderNumber,

ALLEXCEPT (

Sales,

Sales[CustomerKey]

)

)

RETURN

Position

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
AllisonKennedy
Super User
Super User

@lt79_Pax  It depends on your end goal. Try this as a new column in the table instead of measure. 


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

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