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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Beefheart
Helper I
Helper I

Circular Dependency?

Hello,

I have a Customers table that’s linked to a Transactions Table and am using Direct Query mode.

I’ve created a calculated column on the customers table that finds the date of the customer’s earliest sales order:

 

FirstSalesOrderDate =

    CALCULATE(

        MIN('Transactions'[Date]),

        'Transaction'[Type] = "Sales Order"

        && 'Transaction'[State] <> "Closed"

        && 'Transaction'[State] <> "Cancelled"

    )

 

This works as desired.

My problems occur when I try and add a second calculated column to the Customers table that returns a date with just the year and month from the FirstSalesOrderDate. EG: The date 2023-05-24 becomes 2023-05-01:

FirstSOMonthYear =

       DATE(YEAR([FirstSalesOrderDate]), MONTH([FirstSalesOrderDate]), 1)


This creates a circular dependency for some reason, yet FirstSalesOrderDate in no way references FirstSOMonthYear.

I’ve also tried changing the calculated column FirstSOMonthYear to this:

 

firstSOMonthYear =

 VAR theDate = CALCULATE(

        MIN('Transaction Header'[Date]),

        'Transaction Header'[Type] = "Sales Order"

        && 'Transaction Header'[State] <> "Closed"

        && 'Transaction Header'[State] <> "Cancelled"

    )

 

RETURN DATE(YEAR(theDate), MONTH(theDate), 1)

 

This too results in a circular dependency, yet it in no way references the first calculated column.

What I want to know is why I’m seeing this behaviour, and what I can do to avoid it.
Can anyone help please?

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Beefheart 

Please try

FirstSalesOrderDate =
MINX (
FILTER (
'Transaction',
'Transaction'[Type] = "Sales Order"
&& 'Transaction'[State] <> "Closed"
&& 'Transaction'[State] <> "Cancelled"
&& 'Transaction'[Customer Key] = 'Customers'[Customer Key]
),
'Transactions'[Date]
)

Hello taberj1,

 

Thank you for taking the time to consider my problem and reply. But I wasn't after a working dax query, sorry if I implied that.

 

What I want to know is why it's happening, what's causing this behaviour? And why does it happen when the two columns are in no way referencing each other? I want to learn what the issue is 🙂

 

Thanks again for your time!

 

Beefheart

 

@Beefheart 

What kind of relationship between the two tables?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors