Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
summer18
Helper III
Helper III

Circular dependency error in switch(true)

I need help on resolving circular dependency error on my formula:

Sales Level =
SWITCH(TRUE(),
'Sales'[Sales by Product]>=1000000,"Level1",
'Sales'[Sales by Product]<=999999 && 'Sales'[Sales by Product]>=500000,"Level2",
'Sales'[Sales by Product]<=499999 && 'Sales'[Sales by Product]>=100000,"Level3",
"Level4"
)

 

The formula for "Sales by Product" which was used in column above:

Sales by Product =
SUMX(
          KEEPFILTERS(VALUES('Sales'[ProductID])),
          CALCULATE(SUM('Sales'[Actual]))
           )

 

Hoping for any assistance.

 

1 ACCEPTED SOLUTION

Hi @summer18 ,

Is Sales by Product a calculated column? If so try this instead:

 

Sales by Product =
CALCULATE (

    SUM ( 'Sales'[Actual] ),

    ALLEXCEPT( 'Sales'[ProductID] )

)

 

Have a read of 

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

 

Which explains why you get circular dependency.

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

6 REPLIES 6
sowjanya123
Frequent Visitor

Hi,

I need help on resolving circular dependency error on my formula:

Below is the calculated column: 

Retro Test Support =
SWITCH(TRUE(),
[FraudPoint LY Revenue]>=100000 && Fraudpoint_Customers[Customer Type Flag]=0,"National Support",
[FraudPoint CY Revenue]>=10000 && Fraudpoint_Customers[Customer Type Flag] = 1,"Strategic Support"
)
FraudPoint CY Revenue is a measure
FraudPoint LY Revenue = CALCULATE([Sum of LY Revenue],FILTER(Fraudpoint_Customers,DISTINCTCOUNT(Fraudpoint_Customers[customer_account_sk])))
Sum of LY revenue is also a measure:
Sum of LY Revenue = CALCULATE([Total Revenue], FILTER(ALL('Date'), 'Date'[Closed Revenue Index by Year]=-1))
Total Revenue is also a measure:
Total Revenue = CALCULATE(SUM('fact_revenue_usage'[Total Billed Charges]),FILTER(Customers,DISTINCTCOUNT(Customers[customer_account_sk])))
Looking forward for help on how to fix the circular dependency error coming in Retro Test Support calculated column
 
 
 
PijushRoy
Super User
Super User

Hi @summer18 

Please try this
Sales Level =
SWITCH(TRUE(),
'Sales'[Sales by Product]>=100000,"Level3",
'Sales'[Sales by Product]>=500000,"Level2",
'Sales'[Sales by Product]>=1000000,"Level1",
"Level4"
)

 

If not work, please share sample data or pbix file.
If solve your requirement, please mark this answer as SOLUTION
If this comment helps you, please LIKE this comment/Kudos

Hi @PijushRoy , it did not work.  I think I have to remove the circular dependency on ProductID but I don't know how.

Hi @summer18 ,

Is Sales by Product a calculated column? If so try this instead:

 

Sales by Product =
CALCULATE (

    SUM ( 'Sales'[Actual] ),

    ALLEXCEPT( 'Sales'[ProductID] )

)

 

Have a read of 

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

 

Which explains why you get circular dependency.

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

thank you @bcdobbs , it works!

Hi @summer18 
Please paste some sample data

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.