Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Create a numbered column in a DAX created table

Hello all, 

I have created a new table (with only 1 column) from DAX to showcase the week numbers for my charts, however, when I add them to charts they do not go in ascending order. I try sort by column but it only shows me the one column already in that DAX table. I know I need to create a sort column with numbers but I am struggling to add a numbered / sort column to the table below:

I have tried generate series formula but it returns an error of 'multiple values found'. Any tips of how to add in a numbered column list to sort the weeks in ascending order in my charts.

 

Thanks!

  • As part of your table DAX code you could add a sorting column, something like this.

    Dimensioni FINYEARWEEK = 
    VAR Table1 =
        DISTINCT ( 'Toll People Labour'[FinYearWeek] )
    VAR Table2 =
        DISTINCT ( 'AUS Casuals'[FinYearWeek] )
    RETURN
        ADDCOLUMNS (
            DISTINCT ( UNION ( Table1, Table2 ) ),
            "Sort", VALUE ( MID ( [FinYearWeek], 3, 2 ) ) * 100 + VALUE ( RIGHT ( [FinYearWeek], 2 ) )
        )

2 Replies

  • As part of your table DAX code you could add a sorting column, something like this.

    Dimensioni FINYEARWEEK = 
    VAR Table1 =
        DISTINCT ( 'Toll People Labour'[FinYearWeek] )
    VAR Table2 =
        DISTINCT ( 'AUS Casuals'[FinYearWeek] )
    RETURN
        ADDCOLUMNS (
            DISTINCT ( UNION ( Table1, Table2 ) ),
            "Sort", VALUE ( MID ( [FinYearWeek], 3, 2 ) ) * 100 + VALUE ( RIGHT ( [FinYearWeek], 2 ) )
        )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you! It worked perfectly!