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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kfschaefer
Helper IV
Helper IV

Reset INDEX order when data sort does not give the results

Looking for solution to reset the INDEX numbering to allow for self determined numbering when Data Asc order does not return the correct results.  See how the 3000+  comes before 501-3000.  is there a way to manuallly reassign the index?

 

Capture.PNG

 

Need help with the following if statement for PowerBI

if [#"# Lives Range"] = "0-100" then 1 
else 
if [#"# Lives Range"] = "101-500" then 2 
else 
if [#"# Lives Range"] = "501-3000" then 3 
else 
if [#"# Lives Range"] = "3000+" then 4 
else 
if [#"# Lives Range"] = "New" then 5 
else 
if [#"# Lives Range"] = "Runout" then 6

Trying to create a unique Index to place the list in correct order - due to the 3000+ value does not place it correctly in ascending order.

1 ACCEPTED SOLUTION


@kfschaefer wrote:

thanks for the code, however, it seems to have and issue with the 4.

Capture.PNG


@kfschaefer

I thought you were adding a column in the modeling lab with DAX, the switch is a DAX function.
To add a column with the same logic in the Query Editor which Power Query is used, you can reference below expression.

 

if [live range]="0-100" then 1 else(
  if [live range]="101-500" then 2 else(
  if [live range]="501-3000" then 3 else(
  if [live range]="3000+" then 4 else(
  if [live range]="New" then 5 else(
  if [live range]="Runout" then 6 else 999)))))

Capture.PNG

 

If you have any question, feel free to let me know.

View solution in original post

9 REPLIES 9
Eric_Zhang
Employee
Employee

@kfschaefer

You can new a column in the modeling lab with the below expression.

NewIndex = SWITCH(Sheet1[live range],"0-100",1,"101-500",2,"501-3000",3,"3000+",4,"New",5,"Runout",6)

Capture.PNG

thanks for the code, however, it seems to have and issue with the 4.

Capture.PNG


@kfschaefer wrote:

thanks for the code, however, it seems to have and issue with the 4.

Capture.PNG


@kfschaefer

I thought you were adding a column in the modeling lab with DAX, the switch is a DAX function.
To add a column with the same logic in the Query Editor which Power Query is used, you can reference below expression.

 

if [live range]="0-100" then 1 else(
  if [live range]="101-500" then 2 else(
  if [live range]="501-3000" then 3 else(
  if [live range]="3000+" then 4 else(
  if [live range]="New" then 5 else(
  if [live range]="Runout" then 6 else 999)))))

Capture.PNG

 

If you have any question, feel free to let me know.

The code worked as far as creating a new index renumbering,  However, when I attempt to use it as a slicer the fliter order reverts back to the alpha sorting and not on the new index. 

 

I created a table, inserted the two columns LivesRange and SortID, still displaying the correct order, when I change the visualization to Slicer it here where the corrected order is lost.

 

I changed the Management relationship to have the LivesRange as the first linked to the Lives Range in the PowerBIData table via the LivesRange Name.   I would prefer not to have the SORTID displayed on my Visualization.

 

See attachments:

 

Capture.PNGCapture2.PNGCapture3.PNGWhen I change from table to slicer it reverts.

 

I am also having the same issue with the Month Slicer.

Thank your for your patience and assistance. 

 

A very gratefull newbie.

 

K

@kfschaefer I'm not really sure if this is what your after, but you can sorty your Lives Range column by the index column so it always returns in proper index order. Go to modeling tab - highlight the Lives Range - select Sort by column in top ribbon and sort by index. 


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

However the 3000+ is sorted out of order when I use the Index column.

 

I need the 3000+ to be displayed after the 500-3000 record, hence the need for manual changing the index to correct this issue.

 

Thanks for your input.

 

 

@kfschaefer It sounds like you just need another column to sort by. @Eric_Zhang provides you with the path to create that new column, but you can manually build it as well. Just create a column that would correspond to the correct order and sort by that column for the order that you want... Is there something else I'm missing?


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

There is a minor issue with his solution, waiting on reply.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.