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
AUaero
Responsive Resident
Responsive Resident

DAX - extract a column from SUMMARIZECOLUMNS

Hi,

 

I'm having trouble with this one.  I want to extract a column from a table variable created using SUMMARIZECOLUMNS and then calculate the median of the values in that column.  I've got the following that returns the table:

 

EVALUATE

VAR MedianTable =
SUMMARIZECOLUMNS(
    Order_Taken_By[USER_NAME],
    "Unique Customers", Customers[UNIQUE_CUSTOMERS],
    "Unique Customers Rank",
        RANKX(
            ALLSELECTED(Order_Taken_By[USER_NAME]),
            Customers[UNIQUE_CUSTOMERS]
        )
    )
    
RETURN MedianTable

Now I want to use the MEDIAN function to get the median values for the "Unique Customers" and "Unique Customers Rank" column.  When I replace the RETURN line in the code above with the following:

 

RETURN MEDIAN(MedianTable[Unique Customers Rank])

 

I get the following error "Table variable 'MedianTable' cannot be used in current context because a base table is expected."

 

Any ideas on how get the column from the table variable and pass it to the MEDIAN function?

 

Thanks!

 

1 ACCEPTED SOLUTION
Mi2n
Employee
Employee
3 REPLIES 3
v-danhe-msft
Employee
Employee

Hi @AUaero ,

Could you please post some simple sample data and your desired result to have a test if possible? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, I have a measure working as follows:

VAR SummaryTable = 
ADDCOLUMNS(
	SUMMARIZE(
        FILTER(
            ALL(Order_Taken_By),
            Order_Taken_By[USER_NAME] <> BLANK() &&
            Order_Taken_By[JOB_TITLE] = "Sales Person"
        ),
		Order_Taken_By[USER_NAME]
	),
	"Value", 
	CALCULATE(
		Customers[UNIQUE_CUSTOMERS],
		FILTER(
			ALL('Calendar'), 
			'Calendar'[PREVIOUS_QTR_FLAG] = "PREVIOUS QUARTER"
		)
    )
)

RETURN MEDIANX(SummaryTable, [Value])
Mi2n
Employee
Employee

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.