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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
maracles
Resolver II
Resolver II

Self Referencing CALCULATEDTABLE()

I have the following calcualted table:

Customer First Medium = 
	SELECTCOLUMNS( 
		CALCULATETABLE(
			'Opportunity Description',
			'Opportunity Description'[Found in GA] = "Found"
		),
		"Order Number",[Order Number],
		"Email", [Email],
		"Medium Friendly", [Medium Group]	
	)
	

However I want to add an addition column using ADDCOLUMNS() but I want it to be based on the calculated table created above. Is this possible? The first parameter for ADDCOLUMNS() is a table name, but giving it the table name of "Customer First Medium" does not do anything. 

To give a usecase. The calcualted table creates a filtered table from my main table "Opportunity Description". I know want to rank this filtered table by adding the following ranking column:

RANKX(
    FILTER(
         Customer First Medium,
         [Email]=EARLIER(Customer First Medium[Email])),
         [Order Number],
         [Order Number],1
         ,DENSE)


How would I do this? Thanks. 

 

1 REPLY 1
v-sihou-msft
Microsoft Employee
Microsoft Employee

Hi @maracles

 

According to your description, you want to add a rank column into your calculated table. Right?

 

In DAX, ADDCOLUMNS() function will return a new table contains original column and add columns. This is based on a created table. But we can't generate this calculated table with rank column through one DAX, it's not possible to achieve this "Self Referencin​g". Because when revolving the RANKX() function, the table is not created completely yet, however this rank column is also a part of table, it is running into paradox. So for your requirement, since you have generated the calcualted table first, you can do modeling on your dataset and add calculated column with RANKX() function populated.

 

Capture.PNG

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.