Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I'm trying to create a user-defined function in DAX where the function receives a table as an input parameter, and then uses that table inside the function. The function is supposed to work with fixed column names, so the structure of the input table is known.
Here is a simplified version of what I'm trying to do:
The logic works correctly when I manually replace SelectedTable with the actual table name.
However, when I use the parameter as shown above, the measure throws an error saying that the table SelectedTable cannot be found.
I’ve tried different parameter data types, but so far I haven’t found any way to make this work.
Is there a way to pass a table as a parameter while keeping the column names fixed?
Thanks in advance!
Solved! Go to Solution.
Hi @brenda89111,
this is a known DAX limitation and expected behavior, While you can pass a table as a parameter to a DAX user-defined function, DAX does not allow referencing columns with table-qualified notation (Table[Column]) inside the function when the table is coming from a parameter.
To make it work, you first need to rebuild the column names inside the function using SELECTCOLUMNS, and then you can use them normally.
Thanks,
Prashanth
Hi @brenda89111,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by community members for your issue worked for you or let us know if you need any further assistance?
Your feedback is important to us, Looking forward to your response
Thanks,
Prashanth
Hi @brenda89111,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by community members for your issue worked for you or let us know if you need any further assistance?
Your feedback is important to us, Looking forward to your response
Thanks,
Prashanth
Hi @brenda89111,
this is a known DAX limitation and expected behavior, While you can pass a table as a parameter to a DAX user-defined function, DAX does not allow referencing columns with table-qualified notation (Table[Column]) inside the function when the table is coming from a parameter.
To make it work, you first need to rebuild the column names inside the function using SELECTCOLUMNS, and then you can use them normally.
Thanks,
Prashanth
Thanks for your reply.
Unfortunately this doesn't work. "Summarize expects a column name as argument".
I also use some other DAX functions in my UDF. The Dax isn't the problem, because it works outside of the UDF. It is about how to correctly apply a table reference in the UDF.
I don't see any difference between what I proposed and what you're actually getting.
Can you explain specifically what you're hoping to achieve, using a real-life example?
I'm trying to calculate unique combinations of a subset of columns in different fact tables.
In VAR Combos you see a subset of this columns, but the actual list is longer.
IN VAR FilteredCombos I apply different filtering steps to only keep the records I'm interested in. I can't share my full code, but this is a subset of what I'm doint.
The end result is a count of unique combinations that meet my requirements.
I currently have to repeat this long measure for every fact table I want to have this count in, so that is why I want to have a UDF.
A measure could look like this:
My Measure1 = My_Function(FACT_SALES)
Pls try this
function MyFunction=
(
SelectedTable : anyref EXPR
) =>
VAR SummarizeTable =
SUMMARIZE(
SelectedTable,[Customer Key]
)
RETURN
COUNTROWS ( SummarizeTable )
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 133 | |
| 88 | |
| 85 | |
| 68 | |
| 64 |