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
john-paul
Frequent Visitor

Occurence number or rank for calculated column

Hi,

 

Hoping someone can help me add a calculated column that ranks or counts occurrence number of a Product Id within a Region based on the order number.

 

Where there are multiple instances of the Product Id sold within a Region, then the earliest Order is ranked or counted 1st.

 

Thanks.

 

RegionProduct IdOrderSalesExpected Value
North9011000011001
North9011000021002
North9021000031201
North9021000041202
North9021000051203
West9011000061001
West9021000071201
West9021000081202
West9031000091301
West9031000101302
East9011000111001
East9011000121002
East9011000131003
East9021000141201
East9031000151301
East9031000161302
South9011000171001
South9011000181002
South9011000191003
South9011000201004
South9011000211005
South9031000221301

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Create new column as 

column = CALCULATE(count(Table1[Order]);FILTER(Table1;Table1[Region]=EARLIER(Table1[Region])&&Table1[Product Id]=EARLIER(Table1[Product Id])&&Table1[Order]<=EARLIER(Table1[Order])))


I hope it works for you

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Create new column as 

column = CALCULATE(count(Table1[Order]);FILTER(Table1;Table1[Region]=EARLIER(Table1[Region])&&Table1[Product Id]=EARLIER(Table1[Product Id])&&Table1[Order]<=EARLIER(Table1[Order])))


I hope it works for you

 

Thank you alsasloren.

That is awesome it worked perfectly!

 

Can the formula also be modified as a measure?

Anonymous
Not applicable

Hi @john-paul 
Please check the below code.

Measure = CALCULATE(
COUNT(Table1[Order]);
FILTER(ALL(Table1);
SUMX(FILTER(Table1;EARLIER(Table1[Region])=Table1[Region]);Table1[Column])&&
SUMX(FILTER(Table1;EARLIER(Table1[Product Id])=Table1[Product Id]);Table1[Column])&&
SUMX(FILTER(Table1;EARLIER(Table1[order])<=Table1[Order]);Table1[Column])
)
)

Thanks again alsasloren for the quick response.

 

I wasn't able to get this one to work. I changed each of the Table1[Column] references to Region, Poduct Id and Order.

Do I need to have these inside another function?

 

Anonymous
Not applicable

Hi again I forgot to declare column content.

 

Actually it wasn't so important but i have to create it. just create new column and give a value as 1

 

Like;
column = 1

 

 

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