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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Freece4802
Frequent Visitor

Why does CALCULATETABLE not register as a single column when used as TREATAS

Hi all, 

 

I was hoping to understand why using a variable which uses calculate table and has only 1 column can't be used within a TREATAS function?  Its easy to overcome by using SELECTEDCOLUMN over a CALCULATETABLE but was just hoping to understand why this is required. See example code below:

 

VAR RewnewedPolicies =
        SELECTCOLUMNS(CALCULATETABLE(
            VALUES ( Fact_VT[PN] ),
            USERELATIONSHIP('Date Table'[Date],Fact_VT[StartDate])),
            "__PN", Fact_VT[PN])

RETURN
    CALCULATE ([Gross Incurred Claims],
        TREATAS ( RewnewedPolicies, Fact_Claims[PN] )
    )
1 ACCEPTED SOLUTION
andrewsommer
Super User
Super User

When doing it without just CALCULATETABLE like this:

VAR RewnewedPolicies =
    CALCULATETABLE(VALUES(Fact_VT[PN]), ...)


you will get a single-column table, but the column retains its original metadata and name (Fact_VT[PN]).  TREATAS cannot reliably bind a source column with metadata tied to another table into a new context without ambiguity.

 

SELECTCOLUMNS flattens this ambiguity, you get a column with a defined name ("__PN")

 

So, effectively, SELECTCOLUMNS is your insurance policy that the shape of the table matches TREATAS' expectations.

 

Please mark this post as a solution if it helps you. Appreciate Kudos.

View solution in original post

2 REPLIES 2
andrewsommer
Super User
Super User

When doing it without just CALCULATETABLE like this:

VAR RewnewedPolicies =
    CALCULATETABLE(VALUES(Fact_VT[PN]), ...)


you will get a single-column table, but the column retains its original metadata and name (Fact_VT[PN]).  TREATAS cannot reliably bind a source column with metadata tied to another table into a new context without ambiguity.

 

SELECTCOLUMNS flattens this ambiguity, you get a column with a defined name ("__PN")

 

So, effectively, SELECTCOLUMNS is your insurance policy that the shape of the table matches TREATAS' expectations.

 

Please mark this post as a solution if it helps you. Appreciate Kudos.

Amazing explanation, much appriciated and good to understand. 

 

Thanks, 

Will 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (4,154)