Forum Discussion

maryfree86's avatar
maryfree86
Frequent Visitor
1 year ago
Solved

Assign different value based on other column's value

Hello,   I would like to make a new column based on the condition of my other columns. Example as below. Column A to D is my dataset and column E will be the column that I would like to create in p...
  • v-csrikanth's avatar
    1 year ago

    Hi maryfree86 
    Sorry for the late response.
    Thank you for being part of the Microsoft Fabric Community.

    The error you're getting "A circular dependency was detected" — is due to the calculated column referencing itself ([Assign Value]) inside its own logic. DAX calculated columns cannot look forward or access their own value while being evaluated row by row.

    You want to check for previous rows with the same ID, Date, and Frequency, and reuse the assign value from there if matched, otherwise generate a new value "AAA" & Index.

    To avoid the circular reference, we must calculate this without ever referring to [Assign Value] itself.

    Please check the updated Dax as follows:
    -----------------------------------------------------------
    Assign Value =

    VAR CurrentIndex = 'Table'[Index]

    VAR CurrentID = 'Table'[ID]

    VAR CurrentDate = 'Table'[Date]

    VAR CurrentFreq = 'Table'[Freq]

    VAR MatchedIndex =

    CALCULATE(

        MIN('Table'[Index]),

        FILTER(

            'Table',

            'Table'[Index] < CurrentIndex &&

            'Table'[ID] = CurrentID &&

            'Table'[Date] = CurrentDate &&

            'Table'[Freq] = CurrentFreq

        )

    )

    RETURN

    IF(

        ISBLANK(MatchedIndex),

        "AAA" & CurrentIndex,

        "AAA" & MatchedIndex

    )
    -----------------------------------------------------------

    If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
    Best Regards,
    Community Support Team _ C Srikanth.