Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I built in Excel a model that I wish to replicate in DAX.
the problem is that I get Circular depedency in DAX.
In Excel I do not get errors because the forumlas use Index and level to calculate in a given order, for instance:
Requirement from Above=IF([@Level]=0,[@Qty],SUMIFS([Missing Qty],[Material],[@[Father Above]],[Index],[@Index],[Level],"<"&[@Level]))
Stock available=MAX(0,[@Stock]-SUMIFS([Consumption],[Material],[@Material],[Index],"<"&[@Index]))
Consumption is the difference between those two fields, and missing Qty is requirement- consumption.
How can I solve it in DAX?
clearly, it returns error as soon as two fields are linked to each other, ignoring the fact the formula structure avoids dependency at the same level.
regards
@MagikJukas Instead of using SUMIFS, you can use DAX functions like SUMX or FILTER to iterate over tables and perform calculations.
DAX
RequirementFromAbove =
IF (
Table[Level] = 0,
Table[Qty],
CALCULATE (
SUM ( Table[MissingQty] ),
FILTER (
Table,
Table[Material] = EARLIER ( Table[FatherAbove] ) &&
Table[Index] = EARLIER ( Table[Index] ) &&
Table[Level] < EARLIER ( Table[Level] )
)
)
)
DAX
StockAvailable =
MAX (
0,
Table[Stock] -
CALCULATE (
SUM ( Table[Consumption] ),
FILTER (
Table,
Table[Material] = EARLIER ( Table[Material] ) &&
Table[Index] < EARLIER ( Table[Index] )
)
)
)
Consumption = Table[RequirementFromAbove] - Table[StockAvailable]
MissingQty = Table[RequirementFromAbove] - Table[Consumption]
Proud to be a Super User! |
|
Hello,
thanks for your solution. the problem is that it creates a dependency with among the 4 column.
In Excel you can fix it by writing to sum the values earlier. In DAX it does not work. as soon two column have a potential dependency, you cannot calculate.
I am trying to understand if there are tricks to work around this problem.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |