Forum Discussion
Assign different value based on other column's value
- 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.
Hi maryfree86
I wanted to check if you had a chance to try the suggested solution.
Please let us know if you need any further assistance.
Looking forward to your update!
Thank you.