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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
zidek22
Frequent Visitor

Error cyclic dependency when sorting by calculated column.

Hello data wizards,

 

I have this problem in Power BI desktop. I need to sort months in a matrix according to their year. The months go like this:

 

Jan, Feb, Mar, Apr, May, Dec

 

the December here is from the previous year, so I want:

 

Dec, Jan, Feb, Mar, Apr, May

 

I have created a calculated column that goes like columnForSort = FORMAT(tablename[DateCol]; "YYYYMM") which I want to use for sorting, because there the dates look like this: 201912, 202001, 20202, etc.

 

Perfect, but now when I click on the Date column in the fields tab and then I "sort by column" and choose the new columnForSort it loads for a bit and then an error pops up that reads: 

 

Failed to save modifications to a server. Error: Cyclic dependency detected: tablename[Date], tablename[columnForSort], tablename[Date].

 

I guess the problem is with sorting an original column by a new column that was created in accordance to the original column.

 

Is there a way to work around this?

 

THANK YOU

4 REPLIES 4
amitchandak
Super User
Super User

@zidek22 , I am not sure How you have used it.

But You can not sort a derived column on the base column

 

This how we create a column and its sort column

Month Year = FORMAT([Date],"mmm-yyyy")
Month Year sort = FORMAT([Date],"yyyymm")

 

Month= FORMAT([Date],"mmm")
Month sort = FORMAT([Date],"mm")

 

Both coming from same column, Not A-> b-> C

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you for your reply @amitchandak !

 

I have a base column and I made one derived column. Then I highlight the base column and click "sort by column" and choose the derived column. I've already done this in a different project where I needed to sort months chronologicaly and not alphabeticaly and it worked great. I'm probably just doing some small mistake. Anyway, thank you for your time!

@zidek22 , I have given formulas in last update to sort the month on month order, not the text. Just adjust to your table and that will work

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

It worked! I added a second DateView column that I use to display the dates, then I created the DateSort column that is in a YYYYMM format and can be sorted. After that I sorted the DateView column by the DateSort column. Basicaly I never use the original Date column in my visual. Just writing this up for future reference if anyone needs it.

 

Thank you so much! Bye @amitchandak 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors