Forum Discussion

zahirmohideen's avatar
1 year ago
Solved

DAX equivalent for DENSE_RANK Window function with KEEP clause

Hello ,    Here is the sample use case.  This table has all the job code for the employees and has one record per employee and hire_date. What would be the DAX equivalent of the following sql "mo...
  • Jihwan_Kim's avatar
    1 year ago

    Hi, 
    I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

    Please check the below picture and the attached pbix file.

    The below formula is for creating table, and I tried to use TREATAS and INDEX DAX functions.

     

     

    INDEX function (DAX) - DAX | Microsoft Learn

     

    TREATAS function - DAX | Microsoft Learn

     

    expected result table = 
    SUMMARIZECOLUMNS (
        data[emp_id],
        data[job_code],
        data[sal],
        TREATAS (
            INDEX (
                1,
                SUMMARIZE ( data, data[emp_id], data[hire_date] ),
                ORDERBY ( data[hire_date], DESC ),
                ,
                PARTITIONBY ( data[emp_id] )
            ),
            data[emp_id],
            data[hire_date]
        )
    )