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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jdriscoll
Helper I
Helper I

Calling tables as variables in other variable

Hi,

I have a fact table with the following columns: "Completion Date", "Email", "Specific Skill/Industry", and "Experience Level". A Microsoft form feeds an Excel table in SharePoint via Power Automate. Basically we have people do a survey of a self-evaluation on various skills. I am working on a measure wherein I was trying to build a summary table of the average scores for each Specific Skill/Industry across all respondents, then wanted to grab the minimum score and return the corresponding Specific Skill/Industry.  So I built a summary table as a variable in the measure, but then I can't seem to get other variables within the measure to reference this summary table. Here is what I would like to do, but I get errors with it:

 

 

 

Min_Skill = 
VAR Avg_Table =
    SUMMARIZE (
        Survey_Table,
        Survey_Table[Specific Skill/Industry],
        "Avg_Score", AVERAGEX ( Survey_Table, [Latest_Score] )
    )
VAR Min_Val =
    CALCULATE ( MIN ( Avg_Score ), ALL ( Avg_Table ) )
RETURN
    CALCULATE (
        MIN ( Avg_Table[Specific Skill/Industry] ),
        Avg_Table[Avg_Score] = Min_Val
    )

 

 

(Latest_Score is a measure I created to capture only the most recent survey responses for each person, allowing for a person to respond multiple times to the survey. For the purpose of this question, you can treat this measure and the original "Experience Level" column the same.)

 

The measure doesn't seem to recognize the internal links to the Avg_Table or to the Avg_Score summary column within Avg_Table. Is there any way to accomplish this without building a whole separate calculated table?

1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

Min_Skill =
VAR Avg_Table =
// SUMMARIZE should NEVER be used to create
// aggregations. It can only ever be used
// to create groupings of rows from an extended
// table. This is the ONLY safe use of the function
// which is flawed and will not be fixed,
// as confirmed by Microsoft. But you don't need it
// here at all.
ADDCOLUMNS(
    DISTINCT( Survey_Table[Specific Skill/Industry] ),
    "@Avg_Score",
        CALCULATE(
            AVERAGEX(
                Survey_Table,
                [Latest_Score]
            )
        )
    )
VAR Min_Val_Skill =
    MINX(
        topn(
            1,
            Avg_Table,
            [@Avg_Score], ASC
        ),
        Survey_Table[Specific Skill/Industry]
    )
return
    Min_Val_Skill

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

Min_Skill =
VAR Avg_Table =
// SUMMARIZE should NEVER be used to create
// aggregations. It can only ever be used
// to create groupings of rows from an extended
// table. This is the ONLY safe use of the function
// which is flawed and will not be fixed,
// as confirmed by Microsoft. But you don't need it
// here at all.
ADDCOLUMNS(
    DISTINCT( Survey_Table[Specific Skill/Industry] ),
    "@Avg_Score",
        CALCULATE(
            AVERAGEX(
                Survey_Table,
                [Latest_Score]
            )
        )
    )
VAR Min_Val_Skill =
    MINX(
        topn(
            1,
            Avg_Table,
            [@Avg_Score], ASC
        ),
        Survey_Table[Specific Skill/Industry]
    )
return
    Min_Val_Skill

Thanks a bunch, worked like a charm.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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