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

Add an index/order column

I have created a table that I'm using to group data but I need to be able to order it correctly in visulizations and so want to add an index/order column but I can't work out where or how to add another column into the formula used to create the table. 

What I want is a column with 1 - 24 following the order they can been seen in in the table below

AllisonB_0-1739977936027.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AllisonB 

 

Please try this:

Unique Callers Band Table = 
VAR _Table1 = SUMMARIZE(ADDCOLUMNS(GENERATESERIES(1,20,1),"Times Called",FORMAT([Value],"")),[Times Called])
VAR _Table2 = {"21-50"}
VAR _Table3 = {"51-100"}
VAR _Table4 = {"101-200"}
VAR _Table5 = {"201+"}
VAR _UnionTable = ADDCOLUMNS(UNION(_Table1,_Table2,_Table3,_Table4,_Table5),"_NUM",
    VAR _String = IF(CONTAINSSTRING([Times Called],"-"),"-","+")
    VAR _Num = SEARCH(_String,[Times Called],1,BLANK())
    RETURN
    VALUE(IFERROR(MID([Times Called],1,_Num-1),[Times Called])))
RETURN 
SELECTCOLUMNS(_UnionTable,[Times Called],"Sort1",RANKX(_UnionTable,[_NUM],,ASC))

The result is as follow:

vzhengdxumsft_0-1740036439875.png

 

 

Best Regards

Zhengdong Xu
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
Anonymous
Not applicable

Hi @AllisonB 

 

Please try this:

Unique Callers Band Table = 
VAR _Table1 = SUMMARIZE(ADDCOLUMNS(GENERATESERIES(1,20,1),"Times Called",FORMAT([Value],"")),[Times Called])
VAR _Table2 = {"21-50"}
VAR _Table3 = {"51-100"}
VAR _Table4 = {"101-200"}
VAR _Table5 = {"201+"}
VAR _UnionTable = ADDCOLUMNS(UNION(_Table1,_Table2,_Table3,_Table4,_Table5),"_NUM",
    VAR _String = IF(CONTAINSSTRING([Times Called],"-"),"-","+")
    VAR _Num = SEARCH(_String,[Times Called],1,BLANK())
    RETURN
    VALUE(IFERROR(MID([Times Called],1,_Num-1),[Times Called])))
RETURN 
SELECTCOLUMNS(_UnionTable,[Times Called],"Sort1",RANKX(_UnionTable,[_NUM],,ASC))

The result is as follow:

vzhengdxumsft_0-1740036439875.png

 

 

Best Regards

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

parry2k
Super User
Super User

@AllisonB here it is:

 

Table = 
VAR __Table1 = SELECTCOLUMNS ( ADDCOLUMNS ( GENERATESERIES ( 1, 20, 1 ), "Times Called", FORMAT ( [Value], "" ) ), "Index", [Value], "Times Called", [Times Called] )
VAR __Table2 = ROW ( "Index", 21, "Times Called", "21-50" )
VAR __Table3 = ROW ( "Index", 51, "Times Called", "51-100" )
VAR __Table4 = ROW ( "Index", 101, "Times Called", "101-200" )
VAR __Table5 = ROW ( "Index", 201, "Times Called", "201+" )
RETURN 
UNION ( 
    __Table1,
    __Table2,
    __Table3,
    __Table4,
    __Table5
)

 

parry2k_0-1739987659893.png

 

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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
Top Kudoed Authors