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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
emarome94
Helper I
Helper I

Circular Dependencies - Calculated Table

Hi everyone, 

I'm creating a table with the following SUMMARIZE functions:

 

emarome94_0-1666951987621.png

 

The above Dax expression actually create a Table for the purpose I have in mind. 

The problem is that I receive a circular dependecie when I try to create a relationship between the new table 'Table' and the 'Query1' table (which of Customer Number unique values come from)  by using the customer number columns

 

emarome94_1-1666952261745.png


Can someone help me to fix the DAX expression? 

Thanks in advance, 

E

1 ACCEPTED SOLUTION

Don't filter the blank values out and then run the below in DAX Studio or Tabular Editor

EVALUATE
ADDCOLUMNS (
    DISTINCT ( 'Query1'[Customer number] ),
    "Customer type", IF ( CALCULATE ( [Total quantity no fob] ) >= 10000, "Top", "No top" ),
    "Total sales", CALCULATE ( [Total sales no fob] ),
    "Total quantity", CALCULATE ( [Total quantity no fob] )
)

By sorting the results on customer number in first ascending and then descending order you should be able to see whether there are any blanks in the result.

You could also try

DEFINE
    VAR T1 =
        ADDCOLUMNS (
            ALLNOBLANKROW ( 'Query1'[Customer number] ),
            "Customer type", IF ( CALCULATE ( [Total quantity no fob] ) >= 10000, "Top", "No top" ),
            "Total sales", CALCULATE ( [Total sales no fob] ),
            "Total quantity", CALCULATE ( [Total quantity no fob] )
        )

EVALUATE
ROW (
    "total rows", COUNTROWS ( T1 ),
    "total customers", COUNTROWS ( SUMMARIZE ( T1, [Customer number] ) )
)

which should give the same number for both total rows and total customers.

View solution in original post

13 REPLIES 13
johnt75
Super User
Super User

Try

Table1 =
ADDCOLUMNS (
    ALLNOBLANKROW ( 'Query1'[Customer number] ),
    "Customer type", IF ( CALCULATE ( [Total quantity no fob] ) >= 10000, "Top", "No top" ),
    "Total sales", CALCULATE ( [Total sales no fob] ),
    "Total quantity", CALCULATE ( [Total quantity no fob] )
)

Hi @johnt75 ,

It gives the same problem

E

Try it as just

Table1 = ALLNOBLANKROW ( 'Query1'[Customer number] )

and then see if you can create the relationship. It is not clear to me whether the problem lies in the customer number column or in one of the other columns.

@johnt75 johnt75 This work but it gives a many to many relationship. 

The problem is in customer numbers as it retrieves an empty row in addition to the other correct 721 unique values. 

 

If in Power Query I remove the blank rows the relationship work well but I would like to not do that cause cause I need that blank rows in the model: so it's about why ALLNOBLANKROW does not remove that blank values

 

E

Try using DISTINCT in my original code instead of ALLNOBLANKROW

@johnt75 
Same result as of ALLNOBLANKROW

are you sure that the empty value is actually blank and doesn't have a space or some other character in it ?

@johnt75 

I checked the column with an ISBLANK and in fact the "empty" rows are returned as false.

I've already tried to managed the "empty" rows in power query with replace values " " with "" but no success. 

So I think the problem is that and this answer to the topic that I should potentially close, but let me know if you are okay in giving me some tips for handling values like this in PowerQuery

 

Instead of replacing " " with "", replace it with null. You can type null into the "replace with" box.

I have managed to make the empty cells as blank values (therefore isblank columns actually give true for that cells) but the result remains the same in terms of relationship etc. 

 

Can you create the relationship if you just create the table as DISTINCT('Query1'[Customer number]), without the additional calculated columns ?

Yes but only if I filter in PowerQuery the blank values. I mean I understand that those are the problem and I removed them from now

Don't filter the blank values out and then run the below in DAX Studio or Tabular Editor

EVALUATE
ADDCOLUMNS (
    DISTINCT ( 'Query1'[Customer number] ),
    "Customer type", IF ( CALCULATE ( [Total quantity no fob] ) >= 10000, "Top", "No top" ),
    "Total sales", CALCULATE ( [Total sales no fob] ),
    "Total quantity", CALCULATE ( [Total quantity no fob] )
)

By sorting the results on customer number in first ascending and then descending order you should be able to see whether there are any blanks in the result.

You could also try

DEFINE
    VAR T1 =
        ADDCOLUMNS (
            ALLNOBLANKROW ( 'Query1'[Customer number] ),
            "Customer type", IF ( CALCULATE ( [Total quantity no fob] ) >= 10000, "Top", "No top" ),
            "Total sales", CALCULATE ( [Total sales no fob] ),
            "Total quantity", CALCULATE ( [Total quantity no fob] )
        )

EVALUATE
ROW (
    "total rows", COUNTROWS ( T1 ),
    "total customers", COUNTROWS ( SUMMARIZE ( T1, [Customer number] ) )
)

which should give the same number for both total rows and total customers.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.