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
It's been a while since I heard back from you and I wanted to follow up. Have you had a chance to try the solutions that have been offered?
If the issue has been resolved, can you mark the post as resolved? If you're still experiencing challenges, please feel free to let us know and we'll be happy to continue to help!
Looking forward to your reply!
Best Regards,
Community Support Team _ C Srikanth.