Forum Discussion

Ezzeldin's avatar
Ezzeldin
Helper I
3 years ago
Solved

Circular Dependency why using sort by column

Dears,

 

I have 2 calculated columns called: LEVEL_1 and Sorting 

 

 

LEVEL_1 Column is used for grouping and depending on the ID column

 

 

The sorting Column specifies the sort of each value in the LEVEL_1 column

 

 

when I try to use the Sort by column option on the LEVEL_1 column it gives me the following error

 

how can I overcome the Circular Dependency error using DAX or any other solution without relying on an Excel sheet; because I want to make the grouping dynamically generated from the database without user intervention?

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Ezzeldin ,

    Please create the 2 columns in power query.

     

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

     

    Best Regards
    Community Support Team _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Ezzeldin's avatar
    Ezzeldin
    3 years ago

    thank you so much, when I create both columns on the power query it works fine. also, I have done another solution by making both columns reference the ID column not each other.

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Ezzeldin ,

    I have created a simple sample, please refer to my pbix file.

    LEVEL_1 = SWITCH(TRUE(),'Table'[ID]>=250000&&'Table'[ID]<=259999,"Accumulated Depreciation",
    'Table'[ID]>=920000&&'Table'[ID]<=929999,"Bank Clearing Accounts",
    'Table'[ID]>=100000&&'Table'[ID]<=109999,"Cash &Banks",
    'Table'[ID]>=980000&&'Table'[ID]<=989999,"Other clearing Accounts",
    BLANK())
    Column =
    SWITCH (
        TRUE (),
        'Table'[LEVEL_1] = "Accumulated Depreciation", 1,
        'Table'[LEVEL_1] = "Bank Clearing Accounts", 2,
        'Table'[LEVEL_1] = "Cash &Banks", 3,
        'Table'[LEVEL_1] = "Other clearing Accounts", 4,
        5
    )
    

     

     

    When you create a Calculated column in the Report View you will get this error because the column which is created based a Column Cannot Sort the Same column because is Dependent on that Column (with a Formula).

     

     

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

    • Ezzeldin's avatar
      Ezzeldin
      Helper I

      level_1 is created to be used in a P&L visual; so I want when I list level_1 column values in the visual to follow a specific sorting that I specified in the column "Sorting".
      for doing so, on the level_1 column, I choose the "Sort by column" option and then choose the "Sorting" column to sort each value in the Level_1 column by the sorting specified in the "Sorting" Column.
      after doing so the error of Circular Dependency occurs.

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Ezzeldin ,

    If that's the case, I suggest you do it in Power query.

    Please refer to my steps.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NcixDcAgDATAXahTvDHG/7Mg9l8jETHd6dZqPQBY208xixR1qO6wUWTOODS4By+nfooZwy7Fb/cL", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [ID]>=250000 and [ID]<=259999 then "Accumulated Depreciation" else if[ID]>=920000 and [ID]<=929999 then "Bank clearing Accounts" else if [ID]>=100000 and [ID]<=109999 then "Cash &Banks" else if [ID]>=980000 and [ID]<=989999 then "Other Clearing Accounts" else " "),
        #"Renamed Columns" = Table.RenameColumns(#"Added Custom",{{"Custom", "level _1"}}),
        #"Added Custom1" = Table.AddColumn(#"Renamed Columns", "Custom", each if [level _1] = "Accumulated Depreciation" then 1 else if [level _1] = "Bank clearing Accounts" then 2 else if [level _1] = "Cash &Banks" then 3 else if [level _1] = "Other Clearing Accounts" then 4 else 5)
    in
        #"Added Custom1"

    Best Regards
    Community Support Team _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Ezzeldin's avatar
      Ezzeldin
      Helper I

      I already try the custom column in the power query to create the "Sorting" Column and then use the "Sort by column" option on the level_1 column and still I face the same error.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Ezzeldin ,

        Please create the 2 columns in power query.

         

        How to Get Your Question Answered Quickly 

         

        If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

         

         

        Best Regards
        Community Support Team _ Rongtie

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.