<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: TREATAS with variables as inputs in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482081#M133151</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;you can use calculated tables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PA =
VAR a = UNION(
SELECTCOLUMNS(P_A, "ProductKey", P_A[ProductKey], "Name", P_A[Name], "Brand", P_A[Brand])
)

VAR b = UNION(
SELECTCOLUMNS(P_B, "Name", P_B[Name], "Brand", P_B[Brand])
)

EVALUATE
VAR A_TreatAs =
TREATAS ( b, a[ProductKey], b[Name], b[Brand] )
VAR Result =
NATURALLEFTOUTERJOIN ( a, A_TreatAs )
RETURN
Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above measure will create calculated tables "a" and "b" with the UNION and SELECTCOLUMNS functions to structure the columns as needed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this work&lt;BR /&gt;@ me in replies or I'll lose your thread!!!&lt;/P&gt;</description>
    <pubDate>Wed, 18 Oct 2023 01:39:10 GMT</pubDate>
    <dc:creator>DallasBaba</dc:creator>
    <dc:date>2023-10-18T01:39:10Z</dc:date>
    <item>
      <title>TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482070#M133148</link>
      <description>&lt;P&gt;My struggle to learn and comprehend&amp;nbsp;the intricacies of&amp;nbsp;TREATAS continues (not that I'm complaining, learning is fun).&lt;BR /&gt;&lt;BR /&gt;Thanks for solving my previous problem, which was mainly self-inflicted&amp;nbsp;by not paying attention, so here is a new one.&lt;BR /&gt;&lt;BR /&gt;I have the following code calculating a table:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR A_TreatAs =
    TREATAS ( P_B, P_A[ProductKey], P_B[Name], P_B[Brand] )
VAR Result =
    NATURALLEFTOUTERJOIN ( P_A, A_Treatas )
RETURN&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;My previous issue has been solved and it works great.&amp;nbsp; The code uses two input table P_A and P_B which are also calculated tables created in a similar way, basically:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;P_A = 
    UNION(
        SELECTCOLUMNS(table,"Name", column... etc&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;What I would like to do, is to do it without creating the intermediate tables so to have something like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var a =
    UNION(
        SELECTCOLUMNS(P_A,"Name", column... etc

var b =
    UNION(
        SELECTCOLUMNS(P_B,"Name", column... etc

VAR A_TreatAs =
    TREATAS ( b, a[ProductKey], b[Name], b[Brand] )
VAR Result =
    NATURALLEFTOUTERJOIN ( a, A_Treatas )
RETURN
A_TreatAs&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;However I must be doing something&amp;nbsp;wrong or missing something obvious again as TREATAS is not letting me use VARs as column names.&lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 23:57:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482070#M133148</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-17T23:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482081#M133151</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;you can use calculated tables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PA =
VAR a = UNION(
SELECTCOLUMNS(P_A, "ProductKey", P_A[ProductKey], "Name", P_A[Name], "Brand", P_A[Brand])
)

VAR b = UNION(
SELECTCOLUMNS(P_B, "Name", P_B[Name], "Brand", P_B[Brand])
)

EVALUATE
VAR A_TreatAs =
TREATAS ( b, a[ProductKey], b[Name], b[Brand] )
VAR Result =
NATURALLEFTOUTERJOIN ( a, A_TreatAs )
RETURN
Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above measure will create calculated tables "a" and "b" with the UNION and SELECTCOLUMNS functions to structure the columns as needed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this work&lt;BR /&gt;@ me in replies or I'll lose your thread!!!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 01:39:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482081#M133151</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2023-10-18T01:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482118#M133158</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="446607" data-lia-user-login="DallasBaba" class="lia-mention lia-mention-user"&gt;DallasBaba&lt;/a&gt;&amp;nbsp;The calculated tables which are the inputs are used to unpivot the example P_A/P_B tables so I cannot use the column names from the P_A table.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 01:12:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482118#M133158</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-18T01:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482134#M133160</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;you can use the ADDCOLUMNS function to create calculated tables, which preserve the original column names ("Name" and "Brand") from the 'P_A' table. This way, you can use 'P_A' and 'P_B' directly without having to create intermediate tables 'a' and 'b.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The TREATAS function can then work with these tables without any issues.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR A_TreatAs =
TREATAS ( P_B, ADDCOLUMNS(P_A, "Name", P_A[Name], "Brand", P_A[Brand])[ProductKey], P_B[Name], P_B[Brand] )

VAR Result =
NATURALLEFTOUTERJOIN ( P_A, A_TreatAs )

RETURN Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 01:38:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482134#M133160</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2023-10-18T01:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482241#M133169</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="446607" data-lia-user-login="DallasBaba" class="lia-mention lia-mention-user"&gt;DallasBaba&lt;/a&gt;&amp;nbsp;That does not seem to work "Function TREATAS expects a fully qualified column reference as argument number 2."&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 02:57:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3482241#M133169</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-18T02:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3483873#M133265</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;Thanks for letting me know error message using&amp;nbsp;&lt;SPAN&gt;TREATAS&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Function. Let try using&amp;nbsp; the SUMMARIZE function&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR A_TreatAs =
    TREATAS (
        SUMMARIZE(P_B, P_B[ProductKey], P_B[Name], P_B[Brand]),
        SUMMARIZE(P_A, P_A[ProductKey], P_A[Name], P_A[Brand])
    )

VAR Result =
    NATURALLEFTOUTERJOIN ( P_A, A_TreatAs )

RETURN Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The SUMMARIZE function will create temporary tables with the necessary columns, preserving their original names. This should resolve the issue with the TREATAS function. The TREATAS function expects fully qualified column references, and by using SUMMARIZE, you ensure that the column references are in the correct format.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution!&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if this works&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 16:58:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3483873#M133265</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2023-10-18T16:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3484298#M133293</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="446607" data-lia-user-login="DallasBaba" class="lia-mention lia-mention-user"&gt;DallasBaba&lt;/a&gt;&amp;nbsp;Still the same issue.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 22:51:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3484298#M133293</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-18T22:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: TREATAS with variables as inputs</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3484345#M133296</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;can you share the pbix sample data, or replace the code with the following and check if it works for your specific case.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR A_TreatAs =
    TREATAS (
        SUMMARIZE(P_B, P_B[ProductKey], P_B[Name], P_B[Brand]),
        ADDCOLUMNS(
            SUMMARIZE(P_A, P_A[ProductKey], P_A[Name], P_A[Brand]),
            "DummyColumn", 1
        )
    )

VAR Result =
    NATURALLEFTOUTERJOIN ( P_A, A_TreatAs )

RETURN Result&lt;/LI-CODE&gt;&lt;P&gt;Note:&amp;nbsp;A "DummyColumn" will be added to the SUMMARIZE result of P_A to make it a fully qualified table, which can then be used in the TREATAS function. This should bypass the "Function TREATAS expects a fully qualified column reference" error.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 00:38:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TREATAS-with-variables-as-inputs/m-p/3484345#M133296</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2023-10-19T00:38:18Z</dc:date>
    </item>
  </channel>
</rss>

