Forum Discussion

zenz's avatar
zenz
Frequent Visitor
2 years ago
Solved

DAX New Column Error - not enough memory

Hi there,    I am using Power BI Desktop: Version: 2.130.930.0 64-bit (June 2024)   I have a table (data set) is about 60K records, and i need to create a new column to see which ID is removed by...
  • mark_endicott's avatar
    2 years ago

    zenz - Instead of a column, you could create this as a measure. The DAX needs to change slightly, but the below should work for you:

     

    VAR _id =
        SELECTEDVALUE ( 'Table (7)'[id] )
    VAR next_date =
        SELECTEDVALUE ( 'Table (7)'[date] ) + 1
    VAR current_date =
        SELECTEDVALUE ( 'Table (7)'[date] )
    VAR id_next =
        CALCULATETABLE (
            VALUES ( 'Table (7)'[id] ),
            REMOVEFILTERS ( 'Table (7)' ),
            'Table (7)'[date] = next_date,
            'Table (7)'[id] = _id
        )
    VAR max_date =
        CALCULATE ( MAX ( 'Table (7)'[date] ), REMOVEFILTERS ( 'Table (7)' ) )
    RETURN
        SWITCH (
            TRUE (),
            _id IN id_next, 0,
            current_date = max_date, 0,
            NOT ( _id ) IN id_next, -1
        )

    Screenshot below shows it's working for me:

    If this works for you, please mark it as the solution. 

  • mark_endicott's avatar
    2 years ago

    zenz - Please remember to accept this as the solution, it helps others learning DAX find answers to their problems.