<?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: Help Creating Measure Count of  top 5 appearance over 13 weeks in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4915979#M186701</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1459060" data-lia-user-login="AdamJo" class="lia-mention lia-mention-user"&gt;AdamJo&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You’re thinking about this exactly the right way the trick is that DAX doesn’t use loops like C++ or Python, but instead works through filter contexts and iterators.&lt;BR /&gt;&lt;BR /&gt;You can absolutely build the measure you want. Here’s a step‑by‑step approach:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;1. Create a proper week index&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Your WeekYear values like 202551 are fine for display, but subtracting 13 won’t work correctly across year boundaries. The robust way is to build a &lt;STRONG&gt;date table&lt;/STRONG&gt; and add a continuous week index:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WeekIndex =
YEAR ( 'Date'[Date] ) * 100 + WEEKNUM ( 'Date'[Date], 2 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This gives you a numeric key that increases continuously across years. Use this in your slicer instead of the concatenated text.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;2. Rank events within each week&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Add a calculated column to rank events by duration per week:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RankPerWeek =
RANKX (
    FILTER (
        Duration,
        Duration[WeekIndex] = EARLIER ( Duration[WeekIndex] )
    ),
    Duration[DurationHours],
    ,
    DESC
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;3. Flag the top 5&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Create a flag column:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IsTop5 =
IF ( [RankPerWeek] &amp;lt;= 5, 1, 0 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;4. Count appearances over the last 13 weeks&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Now the measure that does the counting:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top5Appearances =
CALCULATE (
    SUMX ( Duration, [IsTop5] ),
    FILTER (
        Duration,
        Duration[WeekIndex] &amp;gt;= MAX ( Duration[WeekIndex] ) - 13
            &amp;amp;&amp;amp; Duration[WeekIndex] &amp;lt;= MAX ( Duration[WeekIndex] )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;5. Use in your visual&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;Put &lt;STRONG&gt;Description&lt;/STRONG&gt; on the X‑axis.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;Put &lt;STRONG&gt;Top5Appearances&lt;/STRONG&gt; on the Y‑axis.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;The slicer for current week drives the MAX(Duration[WeekIndex]).&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;The measure looks back 13 weeks and counts how many times each cause was in the top 5.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;The total count across all causes will be 65 (13 weeks × 5 causes), unless some weeks have fewer than 5 events. Splitting by description will show the breakdown per cause.&lt;BR /&gt;&lt;BR /&gt;In summary: yes, DAX can do exactly what you want. The key is to use a proper week index, rank with RANKX, flag the top 5, and then sum over the last 13 weeks relative to your slicer. That will give you the measure you need for your visual.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jan 2026 17:00:09 GMT</pubDate>
    <dc:creator>Olufemi7</dc:creator>
    <dc:date>2026-01-10T17:00:09Z</dc:date>
    <item>
      <title>Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910564#M186592</link>
      <description>&lt;P&gt;Hi, I have a dataset with a duration of an event and a description. The description is one of a certain fixed set of text values and the duration is in hours. I also have for each event a weekand year number in the following format 202551, meaning week 51 2025. I am attempting to create a measure that can count how many times causes appear in the weekly top 5 (Ordered by duration), so that i can create a visual with the count on my y axis and the description on the x. I have a slicer that works to fix the current week I am looking at for other visuals, and want the measure to use this as the reference for counting back my 13 weeks.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;To me this seems like a relatively simple problem from at least a logic or skeleton code perspective, but I cannot figure out how to make this work,&amp;nbsp; I must caveat that I am new to Dax and come from a more coding specific experience such as Cpp and python.&lt;BR /&gt;&lt;BR /&gt;The skeleton Logic I have is as follows:&lt;/P&gt;&lt;P&gt;Cause count&lt;BR /&gt;End week =Currentweek&lt;/P&gt;&lt;P&gt;Start week = Current week-13&lt;/P&gt;&lt;P&gt;13 week group = Filter(Duration Table, week&amp;gt;start week &amp;amp;&amp;amp; week&amp;lt;End week&lt;/P&gt;&lt;P&gt;i=0&lt;/P&gt;&lt;P&gt;For week in 13 week group:&lt;/P&gt;&lt;P&gt;FilteredWeek= Filter(Duration Table, week= i)&lt;/P&gt;&lt;P&gt;FilteredRank=Rank(FilteredWeek, Order by Failure Duration)&lt;/P&gt;&lt;P&gt;For event in filtered week:&lt;/P&gt;&lt;P&gt;If rank &amp;lt;5, Cause count+=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Return&amp;nbsp; Cause Count&lt;/P&gt;&lt;P&gt;then using a filter on a visual to split it by cause. It should return the count of how many times causes appear in the top 5 over 13 weeks, so the total count without filters should be 65, and then when I split by cause it should be able to be filtered for example to show the top 5.&lt;/P&gt;&lt;P&gt;I hope this Skeleton code makes sense, I am just struggling with how to implement this in a dax query and making it work, I fear it is my own limitations.&lt;/P&gt;&lt;P&gt;Thank you for any assistance, or if this is something that dax just cannot do maybe?&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2025 23:11:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910564#M186592</guid>
      <dc:creator>AdamJo</dc:creator>
      <dc:date>2025-12-30T23:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910598#M186593</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1459060" data-lia-user-login="AdamJo" class="lia-mention lia-mention-user"&gt;AdamJo&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I hope you are doing well today &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;☺️&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this &lt;STRONG&gt;&lt;FONT color="#99CC00"&gt;Dax Measure&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;below which dynamically takes the &lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;selected week from the slicer&lt;/STRONG&gt;&lt;/FONT&gt; and &lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;looks back 13 weeks&lt;/STRONG&gt;&lt;/FONT&gt; and &lt;FONT color="#33CCCC"&gt;&lt;STRONG&gt;counts how many times&lt;/STRONG&gt;&lt;/FONT&gt; each cause appears in &lt;FONT color="#FFCC00"&gt;&lt;STRONG&gt;the Top 5&lt;/STRONG&gt;&lt;/FONT&gt; (ordered by Duration):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Cause Top5 Count (13w) :=
VAR SelWeekIndex = MAX( Week[WeekIndex] )        // drives the window
VAR StartWeekIndex = SelWeekIndex - 12

// 13-week filtered duration table (respects other slicers, removes Week filters)
VAR FilteredDuration =
    CALCULATETABLE(
        'Duration Table',
        ALL( Week ),
        Week[WeekIndex] &amp;gt;= StartWeekIndex,
        Week[WeekIndex] &amp;lt;= SelWeekIndex
    )

// Pre-aggregate once for performance
VAR Summary13 =
    SUMMARIZE(
        FilteredDuration,
        'Duration Table'[WeekCode],
        'Duration Table'[Description],
        "TotalDuration", SUM( 'Duration Table'[DurationHours] )
    )

VAR ThisCause = SELECTEDVALUE( 'Duration Table'[Description] )

// distinct week list from the pre-agg (only weeks that actually have data)
VAR DistinctWeeks =
    DISTINCT( SELECTCOLUMNS( Summary13, "WeekCode", 'Duration Table'[WeekCode] ) )

RETURN
IF(
    ISBLANK( ThisCause ),
    // dynamic total: sum actual top-N counts per week (&amp;lt;= 13*5)
    SUMX(
        DistinctWeeks,
        VAR CW = [WeekCode]
        VAR Top5 =
            TOPN(
                5,
                FILTER( Summary13, [WeekCode] = CW ),
                [TotalDuration], DESC
            )
        RETURN COUNTROWS( Top5 )
    ),
    // per-cause: count weeks where the cause is in that week's top5
    SUMX(
        DistinctWeeks,
        VAR CW = [WeekCode]
        VAR Top5 =
            TOPN(
                5,
                FILTER( Summary13, [WeekCode] = CW ),
                [TotalDuration], DESC
            )
        RETURN IF( COUNTROWS( FILTER( Top5, [Description] = ThisCause ) ) &amp;gt; 0, 1, 0 )
    )
)&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;Replace table and column with your actua names if they different&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;EM&gt;if this post helps, then I would appreciate a thumbs up&lt;/EM&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;and&amp;nbsp;&lt;STRONG&gt;mark it as the solution&lt;/STRONG&gt;&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;to help the other members find it more quickly.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 31 Dec 2025 02:43:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910598#M186593</guid>
      <dc:creator>Ahmed-Elfeel</dc:creator>
      <dc:date>2025-12-31T02:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910694#M186595</link>
      <description>&lt;P&gt;Please try the logic below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top5 Weeks Count (13w) =
VAR EndDate =
    MAX ( 'DimDate'[Date] )           -- driven by your week slicer
VAR Weeks =
    CALCULATETABLE (
        VALUES ( 'DimDate'[YearWeek] ),
        DATESINPERIOD ( 'DimDate'[Date], EndDate, -13, WEEK )
    )
RETURN
SUMX (
    Weeks,
    VAR ThisWeek = 'DimDate'[YearWeek]
    VAR Top5CausesThisWeek =
        TOPN (
            5,
            CALCULATETABLE (
                SUMMARIZE ( Events, Events[Cause], "Dur", [Total Duration] ),
                KEEPFILTERS ( 'DimDate'[YearWeek] = ThisWeek )
            ),
            [Dur], DESC
        )
    RETURN
        IF (
            CONTAINS ( Top5CausesThisWeek, Events[Cause], SELECTEDVALUE ( Events[Cause] ) ),
            1,
            0
        )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 31 Dec 2025 06:46:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910694#M186595</guid>
      <dc:creator>cengizhanarslan</dc:creator>
      <dc:date>2025-12-31T06:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910766#M186597</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1459060" data-lia-user-login="AdamJo" class="lia-mention lia-mention-user"&gt;AdamJo&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution provided by &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="838901" data-lia-user-login="Ahmed-Elfeel" class="lia-mention lia-mention-user"&gt;Ahmed-Elfeel&lt;/a&gt;&amp;nbsp;above will meet the requirement. &lt;BR /&gt;Here are some key points to consider:&lt;/P&gt;
&lt;P&gt;Ensure you use a valid Week dimension with a continuous numeric WeekIndex, as the 13-week lookback logic relies on a sequential index. If your data is missing weeks, it’s best to use a Date/Week table instead of calculating directly from the fact table.&lt;/P&gt;
&lt;P&gt;The week slicer should be based on the Week table, not the duration/event table, to ensure the selected week correctly drives the 13-week window for all visuals.&lt;/P&gt;
&lt;P&gt;The measure aggregates duration at the Week and Cause level before ranking, which ensures it identifies the weekly Top 5 causes by total duration as required.&lt;/P&gt;
&lt;P&gt;Keep in mind, the overall total may be less than 65 if some weeks have fewer than five causes, which is normal and not a calculation error.&lt;/P&gt;
&lt;P&gt;To check the logic, you can create a temporary table visual with Week, Cause, Total Duration, and the measure to see which causes are in the Top 5 each week.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Dec 2025 09:16:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4910766#M186597</guid>
      <dc:creator>v-sgandrathi</dc:creator>
      <dc:date>2025-12-31T09:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4911624#M186617</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, this is a good use case for DAX, but the difficulty comes from trying to think in an imperative / loop-based way.&lt;BR /&gt;DAX is set-based, so instead of looping over weeks, you need to build virtual tables and aggregate over them.&lt;/P&gt;&lt;P&gt;The key idea is:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Identify the last 13 weeks based on the selected week&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;For each week, rank events by duration&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Keep only the Top 5 per week&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Count how many times each cause appears across those weeks&lt;/P&gt;&lt;P&gt;No explicit loops are needed.&lt;/P&gt;&lt;HR /&gt;&lt;H3&gt;Step 1 – Get the selected (current) week&lt;/H3&gt;&lt;P&gt;Assuming you have a slicer on YearWeek (e.g. 202551):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;Selected Week := MAX ( Events[YearWeek] )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;HR /&gt;&lt;H3&gt;Step 2 – Build the 13-week window&lt;/H3&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;Weeks_13 := FILTER ( ALL ( Events[YearWeek] ), Events[YearWeek] &amp;lt;= [Selected Week] &amp;amp;&amp;amp; Events[YearWeek] &amp;gt; [Selected Week] - 13 )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;HR /&gt;&lt;H3&gt;Step 3 – Rank events by duration &lt;STRONG&gt;within each week&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;Rank In Week := RANKX ( FILTER ( ALL ( Events ), Events[YearWeek] = MAX ( Events[YearWeek] ) ), Events[Duration], , DESC, DENSE )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;HR /&gt;&lt;H3&gt;Step 4 – Count appearances in weekly Top 5&lt;/H3&gt;&lt;P&gt;This is the measure you put on the Y-axis, with &lt;STRONG&gt;Description (Cause) on X-axis:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;Top 5 Appearances (13 Weeks) := VAR CurrentWeek = [Selected Week] VAR EventsInScope = FILTER ( ALL ( Events ), Events[YearWeek] &amp;lt;= CurrentWeek &amp;amp;&amp;amp; Events[YearWeek] &amp;gt; CurrentWeek - 13 ) VAR Top5PerWeek = FILTER ( ADDCOLUMNS ( EventsInScope, "WeekRank", RANKX ( FILTER ( EventsInScope, Events[YearWeek] = EARLIER ( Events[YearWeek] ) ), Events[Duration], , DESC, DENSE ) ), [WeekRank] &amp;lt;= 5 ) RETURN COUNTROWS ( Top5PerWeek )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 02 Jan 2026 16:54:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4911624#M186617</guid>
      <dc:creator>sarahlns</dc:creator>
      <dc:date>2026-01-02T16:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4911882#M186620</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1459060" data-lia-user-login="AdamJo" class="lia-mention lia-mention-user"&gt;AdamJo&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please try measure below:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top 5 Cause Count v2 = 
VAR CurrentWeek = SELECTEDVALUE('Duration Table'[WeekYear])
VAR StartWeek = CurrentWeek - 13

// Count how many times this cause appears in top 5 across all weeks
VAR Result = 
    SUMX(
        VALUES('Duration Table'[WeekYear]),
        VAR WeekToCheck = 'Duration Table'[WeekYear]
        VAR IsInRange = WeekToCheck &amp;gt; StartWeek &amp;amp;&amp;amp; WeekToCheck &amp;lt;= CurrentWeek
        VAR CurrentCause = SELECTEDVALUE('Duration Table'[Description])
        
        VAR WeekTotal = 
            CALCULATE(
                SUM('Duration Table'[Duration]),
                'Duration Table'[WeekYear] = WeekToCheck,
                'Duration Table'[Description] = CurrentCause
            )
        
        VAR RankInWeek = 
            RANKX(
                FILTER(
                    ALL('Duration Table'[Description]),
                    CALCULATE(
                        SUM('Duration Table'[Duration]),
                        'Duration Table'[WeekYear] = WeekToCheck
                    ) &amp;gt; 0
                ),
                CALCULATE(
                    SUM('Duration Table'[Duration]),
                    'Duration Table'[WeekYear] = WeekToCheck
                ),
                ,
                DESC,
                DENSE
            )
        
        RETURN
            IF(IsInRange &amp;amp;&amp;amp; RankInWeek &amp;lt;= 5, 1, 0)
    )

RETURN Result&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/11BOqTN-AW5RaKXfvBRC7ztSYbEXKyAwJ/view?usp=sharing" target="_self"&gt;Sample PBIX&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please give kudos or mark it as solution once confirmed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Praful&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jan 2026 13:31:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4911882#M186620</guid>
      <dc:creator>Praful_Potphode</dc:creator>
      <dc:date>2026-01-03T13:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4912239#M186624</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1459060" data-lia-user-login="AdamJo" class="lia-mention lia-mention-user"&gt;AdamJo&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to follow up on our previous suggestions regarding the issue. We would love to hear back from you to ensure we can assist you further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Than you.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2026 04:35:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4912239#M186624</guid>
      <dc:creator>v-sgandrathi</dc:creator>
      <dc:date>2026-01-05T04:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4914348#M186666</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1459060" data-lia-user-login="AdamJo" class="lia-mention lia-mention-user"&gt;AdamJo&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;I wanted to follow up on our previous suggestions regarding the issue. We would love to hear back from you to ensure we can assist you further.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2026 04:30:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4914348#M186666</guid>
      <dc:creator>v-sgandrathi</dc:creator>
      <dc:date>2026-01-08T04:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help Creating Measure Count of  top 5 appearance over 13 weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4915979#M186701</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1459060" data-lia-user-login="AdamJo" class="lia-mention lia-mention-user"&gt;AdamJo&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You’re thinking about this exactly the right way the trick is that DAX doesn’t use loops like C++ or Python, but instead works through filter contexts and iterators.&lt;BR /&gt;&lt;BR /&gt;You can absolutely build the measure you want. Here’s a step‑by‑step approach:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;1. Create a proper week index&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Your WeekYear values like 202551 are fine for display, but subtracting 13 won’t work correctly across year boundaries. The robust way is to build a &lt;STRONG&gt;date table&lt;/STRONG&gt; and add a continuous week index:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WeekIndex =
YEAR ( 'Date'[Date] ) * 100 + WEEKNUM ( 'Date'[Date], 2 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This gives you a numeric key that increases continuously across years. Use this in your slicer instead of the concatenated text.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;2. Rank events within each week&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Add a calculated column to rank events by duration per week:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RankPerWeek =
RANKX (
    FILTER (
        Duration,
        Duration[WeekIndex] = EARLIER ( Duration[WeekIndex] )
    ),
    Duration[DurationHours],
    ,
    DESC
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;3. Flag the top 5&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Create a flag column:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IsTop5 =
IF ( [RankPerWeek] &amp;lt;= 5, 1, 0 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;4. Count appearances over the last 13 weeks&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Now the measure that does the counting:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top5Appearances =
CALCULATE (
    SUMX ( Duration, [IsTop5] ),
    FILTER (
        Duration,
        Duration[WeekIndex] &amp;gt;= MAX ( Duration[WeekIndex] ) - 13
            &amp;amp;&amp;amp; Duration[WeekIndex] &amp;lt;= MAX ( Duration[WeekIndex] )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;5. Use in your visual&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;Put &lt;STRONG&gt;Description&lt;/STRONG&gt; on the X‑axis.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;Put &lt;STRONG&gt;Top5Appearances&lt;/STRONG&gt; on the Y‑axis.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;The slicer for current week drives the MAX(Duration[WeekIndex]).&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;The measure looks back 13 weeks and counts how many times each cause was in the top 5.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;The total count across all causes will be 65 (13 weeks × 5 causes), unless some weeks have fewer than 5 events. Splitting by description will show the breakdown per cause.&lt;BR /&gt;&lt;BR /&gt;In summary: yes, DAX can do exactly what you want. The key is to use a proper week index, rank with RANKX, flag the top 5, and then sum over the last 13 weeks relative to your slicer. That will give you the measure you need for your visual.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jan 2026 17:00:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-Creating-Measure-Count-of-top-5-appearance-over-13-weeks/m-p/4915979#M186701</guid>
      <dc:creator>Olufemi7</dc:creator>
      <dc:date>2026-01-10T17:00:09Z</dc:date>
    </item>
  </channel>
</rss>

