<?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: Adding Switch Results to Matrix (or different solution) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3998249#M155687</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="364977" data-lia-user-login="Mitchell92" class="lia-mention lia-mention-user"&gt;Mitchell92&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you be able to provide an example of data that appears in the wrong category? You could add additional rows to the shared pbix if that's easier.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2024 12:57:50 GMT</pubDate>
    <dc:creator>DataInsights</dc:creator>
    <dc:date>2024-06-18T12:57:50Z</dc:date>
    <item>
      <title>Adding Switch Results to Matrix (or different solution)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3937383#M155684</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm hoping someone may be able to assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a list of invoice #'s with invoice date and amount, and also a calendar table with a relationship between the invoice date and calendar date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the report, I want to be able to select the calendar date using a slicer, and have a table populate the age of the invoice (per selected date), and summarise the invoice amounts by an "age bracket" within a matrix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have achieved two things thus far:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1)&lt;/STRONG&gt; I have been able to calculate the invoice age per selected slicer date using the following measure:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Age2 = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _RangeStart = &lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(AR[TRXDTE])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _RangeEnd = &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(DateTable[Date])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(_RangeStart,_RangeEnd,DAY)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;2)&amp;nbsp;&lt;/STRONG&gt;I have created a measure with a switch formula to distribute ages between age brackets:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;AgeBrackets =&lt;/SPAN&gt; &lt;SPAN&gt;switch&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[Age2]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;30&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"0 - 30"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Age2]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;60&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"31 - 60"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Age2]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;90&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"61 - 90"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Age2]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt; &lt;/SPAN&gt;&lt;SPAN&gt;120&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"91 - 120"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"120+"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;What I am unable to achieve is putting the AgeBrackets measure into a matrix as the column headers (with invoice value as values) to summarise this effectively.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I'm hoping someone has experience with this / may be able to assist? Hoping its a quick and easy solution.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;PBIX LINK:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;A href="https://rizon-my.sharepoint.com/:u:/g/personal/mitchell_luchterhand_rizon_com_au/EUsUk5v0OMZMsxD6SVkh9E4Bl2QeZeT13Fc8EwSrMrj-Ig?e=2VMtgK" target="_self"&gt;PBIX&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 00:48:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3937383#M155684</guid>
      <dc:creator>Mitchell92</dc:creator>
      <dc:date>2024-05-22T00:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Switch Results to Matrix (or different solution)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3939888#M155685</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="364977" data-lia-user-login="Mitchell92" class="lia-mention lia-mention-user"&gt;Mitchell92&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a disconnected table like the one below (no relationships). Sort Age Bracket by Age Bracket Index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create measures:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sum of Total = SUM ( ARITEMA2[Total] )&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;AgeBrackets = 
VAR vLowerBound =
    SELECTEDVALUE ( AgeBracket[Lower Bound] )
VAR vUpperBound =
    SELECTEDVALUE ( AgeBracket[Upper Bound] )
VAR vAge = [Age2]
VAR vResult =
    IF ( vAge &amp;gt;= vLowerBound &amp;amp;&amp;amp; vAge &amp;lt;= vUpperBound, [Sum of Total] )
RETURN
    vResult&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add AgeBracket[Age Bracket] to matrix columns, and [AgeBrackets] to matrix values. You can expand this example to handle totals with a measure like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;AgeBrackets = 
VAR vLowerBound =
    SELECTEDVALUE ( AgeBracket[Lower Bound] )
VAR vUpperBound =
    SELECTEDVALUE ( AgeBracket[Upper Bound] )
VAR vAge = [Age2]
VAR vResult =
    SUMX ( VALUES ( HEADER[OPS] ), IF ( vAge &amp;gt;= vLowerBound &amp;amp;&amp;amp; vAge &amp;lt;= vUpperBound, [Sum of Total] ) )
RETURN
    vResult&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 13:12:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3939888#M155685</guid>
      <dc:creator>DataInsights</dc:creator>
      <dc:date>2024-05-22T13:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Switch Results to Matrix (or different solution)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3940891#M155686</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="207275" data-lia-user-login="DataInsights" class="lia-mention lia-mention-user"&gt;DataInsights&lt;/a&gt;&amp;nbsp;, thank you for your assistance. This has certainly got me a lot further - I have one issue though. On my actual data set, theres about 4 years worth of invoicing. This solution seems to be lumping everything into the max bracket within the category (everything is being categorised as 120+).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wondering if there is a quick solution for that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 22:59:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3940891#M155686</guid>
      <dc:creator>Mitchell92</dc:creator>
      <dc:date>2024-05-22T22:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Switch Results to Matrix (or different solution)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3998249#M155687</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="364977" data-lia-user-login="Mitchell92" class="lia-mention lia-mention-user"&gt;Mitchell92&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you be able to provide an example of data that appears in the wrong category? You could add additional rows to the shared pbix if that's easier.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 12:57:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3998249#M155687</guid>
      <dc:creator>DataInsights</dc:creator>
      <dc:date>2024-06-18T12:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Switch Results to Matrix (or different solution)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3998957#M155688</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="207275" data-lia-user-login="DataInsights" class="lia-mention lia-mention-user"&gt;DataInsights&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PBIX link here:&amp;nbsp;&lt;A href="https://rizon-my.sharepoint.com/:u:/g/personal/mitchell_luchterhand_rizon_com_au/EXdPWuS5bM5JvDa1Nxf7xxEB98Y9y1GD6vxrhIpnSspdaw?e=F6p1d4" target="_blank"&gt;TEST - Debtors Point in Time2.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully you can assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mitch&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 22:42:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3998957#M155688</guid>
      <dc:creator>Mitchell92</dc:creator>
      <dc:date>2024-06-18T22:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Switch Results to Matrix (or different solution)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3999001#M155692</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="364977" data-lia-user-login="Mitchell92" class="lia-mention lia-mention-user"&gt;Mitchell92&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this measure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;AgeBrackets = 
VAR vLowerBound =
    SELECTEDVALUE ( AgeBracket[Lower Bound] )
VAR vUpperBound =
    SELECTEDVALUE ( AgeBracket[Upper Bound] )
VAR vMaxDate =
    MAX ( DateTable[Date] )
VAR vResult =
    SUMX (
        Invoicing,
        VAR vInvDate = Invoicing[Date]
        VAR vAge = DATEDIFF ( vInvDate, vMaxDate, DAY )
        RETURN
            IF ( vAge &amp;gt;= vLowerBound &amp;amp;&amp;amp; vAge &amp;lt;= vUpperBound, [Sum of Total] )
    )
RETURN
    vResult&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 23:26:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Adding-Switch-Results-to-Matrix-or-different-solution/m-p/3999001#M155692</guid>
      <dc:creator>DataInsights</dc:creator>
      <dc:date>2024-06-18T23:26:26Z</dc:date>
    </item>
  </channel>
</rss>

