Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

PRIORITY Number Change and create new column based which number in first position instead one

I have a dataset with two columns. If the "Priority" column has a value of 1, it should be changed to any other number, for example, if it's changed to 3, then 1 will be changed to 3, and 3 will be changed to 1. I have attached a sample data with the desired output.

 

TASKNO   PRIORITY
1                 1
2                2
3                3
4                4
5               5

IF PRIORITY ORDER IF I CHANGE 1 TO 5 .. I WANT OUTPUT LIKE


TASKNO            PRIORITY         TO CHANGE

1                              1                      5
2                              2                     2
3                              3                    3
4                             4                    4
5                            5                      1

 

IF PRIORITY ORDER IF I CHANGE 1 TO 3 .. I WANT OUTPUT LIKE


TASKNO   PRIORITY       TO CHANGE

1                  1                        3
2                 2                         2
3                 3                         1
4                 4                        4
5                 5                       5

 


IF PRIORITY ORDER IF I CHANGE 1 TO 4 .. I WANT OUTPUT LIKE


TASKNO       PRIORITY      TO CHANGE

1                      1                        4
2                     2                         2
3                     3                         3
4                     4                        1
5                    5                         5                                                                                                                                                                  Thanks in advance . 

1 Reply

  • ERD's avatar
    ERD
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous ,

    You can try the measure:

    TO CHANGE = 
    VAR _priority =
        SELECTEDVALUE ( priority[PRIORITY] )
    VAR _priorityToChange =
        SELECTEDVALUE ( 'table'[PRIORITY] )
    RETURN
        SWITCH ( _priorityToChange, 1, _priority, _priority, 1, _priorityToChange )

    Out of curiosity, what's the real life usage?