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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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