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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

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

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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