Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Index based on two date columns

Hello,   I have looked at other posts regarding index columns based on two columns, but i haven't been able to find a solution to my problem.    I have a DAX table with two date colomns (and some...
  • mahoneypat's avatar
    4 years ago

    This is done more easily in the query editor, but since you stated you need a DAX column, this one seems to work.  You'll need to replace Index with your actual table name.

     

     

     

    NewIndex =
    VAR vThisValue =
        INT ( CONVERT ( Index[Purchase date], DATETIME ) )
            INT ( CONVERT ( Index[sales date], DATETIME ) ) / 100000
    VAR vAdd =
        ADDCOLUMNS (
            Index,
            "cValue",
                INT ( CONVERT ( Index[Purchase date], DATETIME ) )
                    INT ( CONVERT ( Index[sales date], DATETIME ) ) / 100000
        )
    RETURN
        RANKX ( vAdd, [cValue], vThisValue, ASC )

     

    Note that I needed to use several Replace Values steps in the query editor to change month names to my locale (e.g., oktober, marts, februrary).

     

    Pat