<?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: DAX macro / dynamically switch table to be used in measures in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124924#M110960</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="527683" data-lia-user-login="spencerhoyle10" class="lia-mention lia-mention-user"&gt;spencerhoyle10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do all tables have the same columns? What differences are there between the tables?&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 19:02:08 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2023-03-10T19:02:08Z</dc:date>
    <item>
      <title>DAX macro / dynamically switch table to be used in measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124854#M110953</link>
      <description>&lt;P&gt;Hi, I am trying to dynamically switch the tables used for specific DAX measures. Ex: I want to know number of rows and sum of a specific column for every table I have imported (assuming each table has the same column to sum)&lt;BR /&gt;&lt;BR /&gt;Let's say I have 3 tables so far...&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Table1&lt;/LI&gt;&lt;LI&gt;Table2&lt;/LI&gt;&lt;LI&gt;Table3&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Let's say I have two measure...&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;NumberOfRows&lt;/LI&gt;&lt;LI&gt;ColumnSum&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Let's say I have a created table that lists the tables...&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;TableID&lt;/TD&gt;&lt;TD&gt;Table Name&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Table2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Table2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Table3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;WHAT I CURRENTLY HAVE:&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The measures look like this...&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;NumberOfRows = SWITCH(Table[ID], 1, COUNTROWS(Table1), 2, COUNTROWS(Table2), 3, COUNTROWS(Table3))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;ColumnSum = SWITCH(Table[ID], 1, SUM(Table1[Column]), 2, SUM(Table2[Column]), 3, SUM(Table3[Column]))&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Currently, if I add new tables to my report, I add the new table expression to each measure!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;WHAT I WANT:&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;To only have to update one DAX measure and all the other measure update as well.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;EX: having a dax measure called "TableUsed" and all my measures use that table&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;TableUsed = SWITCH(1, Table1, 2, Table2, 3, Table3)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;NumberOfRows = COUNTROWS(TableUsed)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;ColumnSum = SUM(TableUsed)&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;This way when I add new tables, all I have to update is the TableUsed measure, and not every single measure it uses.&lt;BR /&gt;Right now I don't know how to havea table be the return value of a measure or how to create any sort of macros / functions for DAX formulas to dynamically change the "text" used in the DAX.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone knows any solution or has any input... Please provide! Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 18:11:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124854#M110953</guid>
      <dc:creator>spencerhoyle10</dc:creator>
      <dc:date>2023-03-10T18:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: DAX macro / dynamically switch table to be used in measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124887#M110959</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="527683" data-lia-user-login="spencerhoyle10" class="lia-mention lia-mention-user"&gt;spencerhoyle10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been always hoping that one day DAX will have functions like IFTABLE or SWITCHTABLE or even tableX functions like UNIONX or EXCEPTX. Unfortunately, as of now this looks more like a dream. What youylooking for is currently not possible.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 18:37:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124887#M110959</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-10T18:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: DAX macro / dynamically switch table to be used in measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124924#M110960</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="527683" data-lia-user-login="spencerhoyle10" class="lia-mention lia-mention-user"&gt;spencerhoyle10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do all tables have the same columns? What differences are there between the tables?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 19:02:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124924#M110960</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-10T19:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: DAX macro / dynamically switch table to be used in measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124993#M110967</link>
      <description>&lt;P&gt;The tables are all different (though they may be related to one another).&lt;BR /&gt;&lt;BR /&gt;However, I am creating a single column in each of them that has the same name. I want to do similar measures on that column across all the tables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 19:54:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3124993#M110967</guid>
      <dc:creator>spencerhoyle10</dc:creator>
      <dc:date>2023-03-10T19:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: DAX macro / dynamically switch table to be used in measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3125016#M110968</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="527683" data-lia-user-login="spencerhoyle10" class="lia-mention lia-mention-user"&gt;spencerhoyle10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reality is always different, however let's assume only one column is involved in the measures. What I would do it to use power query to create a table that selects that column from all of these tables adding the table name as new columns then append in one table.&amp;nbsp;&lt;BR /&gt;in this case the table slicer will be a column in the main table, clicking on a table name will filter the main table down to that table and hence any sum our conunt measure related to that table.&amp;nbsp;&lt;BR /&gt;of course the that might not be ideal as the model and filter requirements from other columns in the original tables shall make this solution not practical or even not applicable.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;other approach can be adding the table name or index as a column to each table then create a table that contains all table names/indexes and then create relationships with the tables. That would be provide more flexibility in respecting other filters in the model.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 20:39:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-macro-dynamically-switch-table-to-be-used-in-measures/m-p/3125016#M110968</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-10T20:39:14Z</dc:date>
    </item>
  </channel>
</rss>

