<?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: Hierarchy Totals &amp;amp; Multiple Slicers using SWITCH/ALL in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1157554#M17718</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This should meet your requirement:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure 3 = 
var __Channel = SELECTEDVALUE('Table'[Channel])
var __VisitType = SELECTEDVALUE('Table'[VisityType])
var __Category = SELECTEDVALUE('Table'[Category])
return
SWITCH(TRUE();
    ISFILTERED('Table'[VisityType]);    DIVIDE(DISTINCTCOUNT('Table'[ID]);
                                                            IF(COUNTROWS(FILTERS('Table'[Channel]))=1;            
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table');'Table'[Channel]=__Channel);
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table'))
                                                                )
                                                )                                                ;
    ISFILTERED('Table'[Channel]);       DIVIDE(DISTINCTCOUNT('Table'[ID]);
                                                            IF(COUNTROWS(FILTERS('Table'[Category]))=1;
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table');'Table'[Category]=__Category);
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table'))
                                                            )
                                                )
;
    ISFILTERED('Table'[Category]);      DIVIDE(DISTINCTCOUNT('Table'[ID]);CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table')))
    )&lt;/LI-CODE&gt;&lt;P&gt;As can be seen here:&amp;nbsp;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;File is available &lt;A href="https://1drv.ms/u/s!AvU6hhKLfmEcgdgd6cMqObWhzoQ0mg?e=rQcSXU" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please mark as solution if this works for you&lt;/STRONG&gt;. Thumbs up for the effort is appreciated.&lt;/P&gt;&lt;P&gt;Kind regards, Steve.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 14 Jun 2020 07:34:00 GMT</pubDate>
    <dc:creator>stevedep</dc:creator>
    <dc:date>2020-06-14T07:34:00Z</dc:date>
    <item>
      <title>Hierarchy Totals &amp; Multiple Slicers using SWITCH/ALL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1156847#M17685</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a simple data model with 1 table (EncounterFact) in PBI. Below is a screenshot of the Excel spreadsheet showing 2 examples of what I'm trying to figure out. The first example contains my sample data and slicer visuals available to select from. In the first example you can see all 3 slicers are active with a selection. The second example shows what should happen if 1 slicer is selected. I've added some notes with the examples, but I want to find the DAX that would work for BOTH the yellow ? boxes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some of the DAX that I started for the measure. I'm hoping some gaps just need to be filled in, but if there is a better way to go about this, please let me know. Thanks!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sample Measure = 
// Measure 1:
VAR ProviderID =
    CALCULATE (
        DISTINCTCOUNT ( EncounterFact[Encounters.ProviderID] ),
        EncounterFact[Encounters.ProviderID] &amp;gt; 0
    ) 
    
// Hierarchy levels in order of smallest (most granular) to largest:
VAR VisitTypeSelected =
    ISFILTERED ( EncounterFact[Encounters.VisitType] )
VAR ChannelSelected =
    ISFILTERED ( EncounterFact[ModalityRevised] )
VAR CategorySelected =
    ISFILTERED ( EncounterFact[ModalityCategory] ) 
    
// Denominator measures based on slicer selection:
VAR VisitTypeTotal =
    CALCULATE ( ProviderID, ALL ( EncounterFact[Encounters.VisitType] ) )
VAR ChannelTotal =
    CALCULATE ( ProviderID, ALL ( EncounterFact[ModalityRevised] ) )
VAR CategoryTotal =
    CALCULATE ( ProviderID, ALL ( EncounterFact ) )
RETURN
    SWITCH (
        TRUE (),
        VisitTypeSelected, VisitTypeTotal,
        ChannelSelected, ChannelTotal,
        CategorySelected, CategoryTotal,
        CategoryTotal
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 01:53:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1156847#M17685</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-13T01:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchy Totals &amp; Multiple Slicers using SWITCH/ALL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1156876#M17687</link>
      <description>&lt;P&gt;Well, &amp;nbsp;believe it or not, a single flat table is not a "simple data model". You would be well advised to create a star schema with dimensions for all of the columns you are trying to filter and modify (with CALCULATE). Most problems normally then go away.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 02:22:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1156876#M17687</guid>
      <dc:creator>MattAllington</dc:creator>
      <dc:date>2020-06-13T02:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchy Totals &amp; Multiple Slicers using SWITCH/ALL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1157044#M17694</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="217" data-lia-user-login="MattAllington" class="lia-mention lia-mention-user"&gt;MattAllington&lt;/a&gt;&amp;nbsp;Thanks so much for the feedback. This table is coming from a single source, an SSAS Tabular cube, which contains this heirarchy and dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know how I might be able to achieve what I'm trying to do? Am I on the right track with the variables and SWITCH, or should I completely go down a different path? I've been stuck on a solution for this for weeks. Thanks again for your help!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 12:18:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1157044#M17694</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-13T12:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchy Totals &amp; Multiple Slicers using SWITCH/ALL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1157425#M17706</link>
      <description>&lt;P&gt;The SSAS cube should already provide all the required dimensions and measures. How does your data source definition look like?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 23:01:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1157425#M17706</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-13T23:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchy Totals &amp; Multiple Slicers using SWITCH/ALL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1157554#M17718</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This should meet your requirement:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure 3 = 
var __Channel = SELECTEDVALUE('Table'[Channel])
var __VisitType = SELECTEDVALUE('Table'[VisityType])
var __Category = SELECTEDVALUE('Table'[Category])
return
SWITCH(TRUE();
    ISFILTERED('Table'[VisityType]);    DIVIDE(DISTINCTCOUNT('Table'[ID]);
                                                            IF(COUNTROWS(FILTERS('Table'[Channel]))=1;            
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table');'Table'[Channel]=__Channel);
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table'))
                                                                )
                                                )                                                ;
    ISFILTERED('Table'[Channel]);       DIVIDE(DISTINCTCOUNT('Table'[ID]);
                                                            IF(COUNTROWS(FILTERS('Table'[Category]))=1;
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table');'Table'[Category]=__Category);
                                                                CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table'))
                                                            )
                                                )
;
    ISFILTERED('Table'[Category]);      DIVIDE(DISTINCTCOUNT('Table'[ID]);CALCULATE(DISTINCTCOUNT('Table'[ID]);ALL('Table')))
    )&lt;/LI-CODE&gt;&lt;P&gt;As can be seen here:&amp;nbsp;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;File is available &lt;A href="https://1drv.ms/u/s!AvU6hhKLfmEcgdgd6cMqObWhzoQ0mg?e=rQcSXU" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please mark as solution if this works for you&lt;/STRONG&gt;. Thumbs up for the effort is appreciated.&lt;/P&gt;&lt;P&gt;Kind regards, Steve.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jun 2020 07:34:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1157554#M17718</guid>
      <dc:creator>stevedep</dc:creator>
      <dc:date>2020-06-14T07:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchy Totals &amp; Multiple Slicers using SWITCH/ALL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1169265#M17996</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;, Hope this works for you?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 15:31:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hierarchy-Totals-amp-Multiple-Slicers-using-SWITCH-ALL/m-p/1169265#M17996</guid>
      <dc:creator>stevedep</dc:creator>
      <dc:date>2020-06-18T15:31:12Z</dc:date>
    </item>
  </channel>
</rss>

