<?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 Display top hierarchy of calendar period based on user selection in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-top-hierarchy-of-calendar-period-based-on-user-selection/m-p/2768049#M86043</link>
    <description>&lt;P&gt;I have a slicer that is organized by Year - &amp;gt; Month Name. I want to a card to display the most convenient/efficient grouping of months. But I'm looking to see if there's a simple way using ISINSCOPE or some other functions to make it "smart". For example, I only want it to display Quarter if complete quarters are selected and return the range in Mmm YYYY format if an "irregular" period is selected. Also, looking to test if the range selected is continuous. If there's a break in selection then display Concatenation of Mmm-YYYY selected periods. See some examples of slicer selections below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date calendar with all the hierarchies and am trying to avoid complicated IF/SWITCH expressions to check for complete hierarchies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Card Output Example Table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Should Display: "Q1 2022"&lt;/TD&gt;&lt;TD&gt;Should Display: "H1 2022"&lt;/TD&gt;&lt;TD&gt;Should Display: "Q4 2021 - Q1 2022"&lt;/TD&gt;&lt;TD&gt;Should Display: "Feb 2022 - May 2022"&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;img /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that makes sense. Thanks in advance for considering!&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2022 18:22:49 GMT</pubDate>
    <dc:creator>scrawfor</dc:creator>
    <dc:date>2022-09-14T18:22:49Z</dc:date>
    <item>
      <title>Display top hierarchy of calendar period based on user selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-top-hierarchy-of-calendar-period-based-on-user-selection/m-p/2768049#M86043</link>
      <description>&lt;P&gt;I have a slicer that is organized by Year - &amp;gt; Month Name. I want to a card to display the most convenient/efficient grouping of months. But I'm looking to see if there's a simple way using ISINSCOPE or some other functions to make it "smart". For example, I only want it to display Quarter if complete quarters are selected and return the range in Mmm YYYY format if an "irregular" period is selected. Also, looking to test if the range selected is continuous. If there's a break in selection then display Concatenation of Mmm-YYYY selected periods. See some examples of slicer selections below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date calendar with all the hierarchies and am trying to avoid complicated IF/SWITCH expressions to check for complete hierarchies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Card Output Example Table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Should Display: "Q1 2022"&lt;/TD&gt;&lt;TD&gt;Should Display: "H1 2022"&lt;/TD&gt;&lt;TD&gt;Should Display: "Q4 2021 - Q1 2022"&lt;/TD&gt;&lt;TD&gt;Should Display: "Feb 2022 - May 2022"&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;img /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that makes sense. Thanks in advance for considering!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 18:22:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-top-hierarchy-of-calendar-period-based-on-user-selection/m-p/2768049#M86043</guid>
      <dc:creator>scrawfor</dc:creator>
      <dc:date>2022-09-14T18:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Display top hierarchy of calendar period based on user selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-top-hierarchy-of-calendar-period-based-on-user-selection/m-p/2769405#M86137</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="243497" data-lia-user-login="scrawfor" class="lia-mention lia-mention-user"&gt;scrawfor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your descriptionAccording to your description, you want to select different years and months according to the slicer to judge, and display different values on the card according to different situations.. Right?&lt;/P&gt;
&lt;P&gt;Here are the steps you can follow：&lt;/P&gt;
&lt;P&gt;(1) We can use the Calendar() function to generate a date table, and we can add the desired dimension to judge:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Date = ADDCOLUMNS( CALENDAR( DATE(2020,1,1),DATE(2022,12,31)),

"Year", YEAR ( [Date] ),

"Quarter", ROUNDUP(MONTH([Date])/3,0),

"year_Q", year([date]) &amp;amp; "Q" &amp;amp; ROUNDUP(MONTH([Date])/3,0),

"year_H", "H" &amp;amp; ROUNDUP(MONTH([Date])/6,0)&amp;amp;" " &amp;amp;YEAR([Date]) ,

"yearmonth", year([Date]) * 100 + MONTH([Date]),

"yearmonth2",YEAR([Date]) &amp;amp;FORMAT( [Date],"mmm")

)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(2)We can ceate a measure : “test_card”&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;test_card =
VAR _slice_YearQ =
    VALUES ( 'Date'[year_Q] )
VAR _slice_Year =
    VALUES ( 'Date'[Year] )
VAR _slice_Q =
    VALUES ( 'Date'[Quarter] )
VAR _slice_date =
    VALUES ( 'Date'[Date] )
VAR _slice_YearMonth =
    VALUES ( 'Date'[yearmonth] )
VAR _slice_YearH =
    VALUES ( 'Date'[year_H] )
VAR _max_date =
    MAXX ( _slice_date, [Date] )
VAR _min_date =
    MINX ( _slice_date, [Date] )
VAR _slice_count_Q =
    DISTINCT (
        SELECTCOLUMNS (
            FILTER (
                ALL ( 'Date'[Date], 'Date'[year_Q] ),
                'Date'[Date] &amp;gt; _min_date
                    &amp;amp;&amp;amp; 'Date'[Date] &amp;lt; _max_date
            ),
            "YearQ", [year_Q]
        )
    )
VAR _slice_count_year_month =
    DISTINCT (
        SELECTCOLUMNS (
            FILTER (
                ALL ( 'Date'[Date], 'Date'[yearmonth] ),
                'Date'[Date] &amp;gt; _min_date
                    &amp;amp;&amp;amp; 'Date'[Date] &amp;lt; _max_date
            ),
            "yearmonth", [yearmonth]
        )
    )
VAR _slice_yearmonthe2 =
    VALUES ( 'Date'[yearmonth2] )
RETURN
    IF (
        COUNTROWS ( _slice_YearQ ) = 1
            &amp;amp;&amp;amp; COUNTROWS ( _slice_YearMonth ) = 3,
        "Q" &amp;amp; _slice_Q &amp;amp; "   " &amp;amp; _slice_Year,
        IF (
            COUNTROWS ( _slice_YearH ) = 1
                &amp;amp;&amp;amp; COUNTROWS ( _slice_YearMonth ) = 6,
            _slice_YearH,
            IF (
                COUNTROWS ( _slice_YearMonth )
                    = 3 * COUNTROWS ( _slice_count_Q ),
                "Q"
                    &amp;amp; ROUNDUP ( MONTH ( _min_date ) / 3, 0 ) &amp;amp; "  "
                    &amp;amp; YEAR ( _min_date ) &amp;amp; "-" &amp;amp; "Q"
                    &amp;amp; ROUNDUP ( MONTH ( _max_date ) / 3, 0 ) &amp;amp; "  "
                    &amp;amp; YEAR ( _max_date ),
                IF (
                    COUNTROWS ( _slice_count_year_month ) = 1,
                    FORMAT ( _min_date, "mmm" ) &amp;amp; "   "
                        &amp;amp; YEAR ( _min_date ),
                    IF (
                        COUNTROWS ( _slice_count_year_month ) = COUNTROWS ( _slice_YearMonth ),
                        FORMAT ( _min_date, "mmm" ) &amp;amp; "   "
                            &amp;amp; YEAR ( _min_date ) &amp;amp; "-"
                            &amp;amp; FORMAT ( _max_date, "mmm" ) &amp;amp; "   "
                            &amp;amp; YEAR ( _max_date ),
                        CONCATENATEX ( _slice_yearmonthe2, [yearmonth2], "," )
                    )
                )
            )
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(3)We can put the [Date] in the slice and put the [test_card] in the card, and then we can meet your need:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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;&lt;img /&gt;&lt;/P&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;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 07:30:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-top-hierarchy-of-calendar-period-based-on-user-selection/m-p/2769405#M86137</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2022-09-15T07:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Display top hierarchy of calendar period based on user selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-top-hierarchy-of-calendar-period-based-on-user-selection/m-p/2772065#M86328</link>
      <description>&lt;P&gt;Awesome, thanks. It works but I was wondering if theres a simpler way to implement? Like working with PATH functions? Maybe the better way to ask the question is, is there a way to display the parent entity if all child entities are selected in a slicer? Hierarchies can get more complicated and with many levels. IF statements become huge as the levels in a hierarchy grows.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 02:46:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Display-top-hierarchy-of-calendar-period-based-on-user-selection/m-p/2772065#M86328</guid>
      <dc:creator>scrawfor</dc:creator>
      <dc:date>2022-09-16T02:46:31Z</dc:date>
    </item>
  </channel>
</rss>

