Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Pawel_1990
Regular Visitor

Flag to mark two lowest values from Table. Grouped by other columns

Hello,

I am using table in direct query mode as source.
Table shows active users already grouped per Month, country, User_Tier, User_Group for last 12 weeks. Example below.

Example table is smaller, but by default each month based on Month_Key has 12 Reported_weeks. Combinations of possible User_Tier, User_Group differs - so it may be 1 row per Reported_week or 5 tows per reported_week.

CountryMonth_KeyReported_WeekUSER_TIERUser_GroupWeekly_Users_Count
PT20240901202428AH20
PT20240901202428BJ10
PT20240901202429AH30
PT20240901202429CH20
PT20240901202430BJ10
PT20240901202430CH30
FR20240901202428BG50
FR20240901202428BT40
FR20240901202429AG100
FR20240901202429AG55
FR20240901202430AG66



Currently there is a measure that caluclates a Weekly number of active users by:
# Weekly Active Users = Calculate(Divide(Sum(Table[Weekly_User_Count]),12))

Is there a possibility at DAX level to change the calculation to take only 10 weeks with best values for each month and country?
So basicly Flag two worst Reported_Week (sum of all combination of User_Tier, User Group).

I tried do it two ways and failed:
Idea #1 - FAILED
- Create Dax measure to detect lowest values. I used "MIN"

Idea #2 - FAILED
- Create a calculated Column to mark rows with lowest values. Again failed, aiming to use "EARLIER"

Thank you gor help

1 ACCEPTED SOLUTION
v-nuoc-msft
Community Support
Community Support

Hi @Pawel_1990 

 

Thank you very much Selva-Salimi for your prompt reply.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"UserActivity"

vnuocmsft_0-1729575224059.png

 

Create a measure.

 

Weekly_Active_Users = 
VAR total_Weekly_Users = SUM(UserActivity[Weekly_Users_Count])
VAR Week_Rank = 
    RANKX(
        FILTER(
            UserActivity,
            UserActivity[Month_Key] = MAX(UserActivity[Month_Key]) 
            && 
            UserActivity[Country] = MAX(UserActivity[Country])
        ),
        total_Weekly_Users,
        ,
        DESC
    )
VAR Top_10_Weekly_Users = 
    CALCULATE(
        SUM(UserActivity[Weekly_Users_Count]),
        FILTER(
            UserActivity,
            Week_Rank <= 10
        )
    )
RETURN
DIVIDE(Top_10_Weekly_Users, 10)

 

Here is the result.

 

vnuocmsft_1-1729575290882.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-nuoc-msft
Community Support
Community Support

Hi @Pawel_1990 

 

Thank you very much Selva-Salimi for your prompt reply.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"UserActivity"

vnuocmsft_0-1729575224059.png

 

Create a measure.

 

Weekly_Active_Users = 
VAR total_Weekly_Users = SUM(UserActivity[Weekly_Users_Count])
VAR Week_Rank = 
    RANKX(
        FILTER(
            UserActivity,
            UserActivity[Month_Key] = MAX(UserActivity[Month_Key]) 
            && 
            UserActivity[Country] = MAX(UserActivity[Country])
        ),
        total_Weekly_Users,
        ,
        DESC
    )
VAR Top_10_Weekly_Users = 
    CALCULATE(
        SUM(UserActivity[Weekly_Users_Count]),
        FILTER(
            UserActivity,
            Week_Rank <= 10
        )
    )
RETURN
DIVIDE(Top_10_Weekly_Users, 10)

 

Here is the result.

 

vnuocmsft_1-1729575290882.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Selva-Salimi
Super User
Super User

Hi @Pawel_1990 

 

it was not that much clear but based on my understanding you need to two worst weeks. so you can do as follows:

 

create a column to calculate the sum of weekly user count based on your expectation....

column sumedup_users = calculate (sum(weeklu_users) , filter (table , x= earlier x (this part should be based on what you want))

 

then you should rank this sumed up weekly users. you can do as follows:

column order = calculate (distinctcount( sumedup_users) , filter (table , sumedup_users < earlier (sumedup users)))

 

then you can use this column in your measure and add a filter to measure to have order greater than 10.

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

"); $(".slidesjs-pagination" ).prependTo(".pagination_sec"); $(".slidesjs-pagination" ).append("
"); $(".slidesjs-play.slidesjs-navigation").appendTo(".playpause_sec"); $(".slidesjs-stop.slidesjs-navigation").appendTo(".playpause_sec"); $(".slidesjs-pagination" ).append(""); $(".slidesjs-pagination" ).append(""); } catch(e){ } /* End: This code is added by iTalent as part of iTrack COMPL-455 */ $(".slidesjs-previous.slidesjs-navigation").attr('tabindex', '0'); $(".slidesjs-next.slidesjs-navigation").attr('tabindex', '0'); /* start: This code is added by iTalent as part of iTrack 1859082 */ $('.slidesjs-play.slidesjs-navigation').attr('id','playtitle'); $('.slidesjs-stop.slidesjs-navigation').attr('id','stoptitle'); $('.slidesjs-play.slidesjs-navigation').attr('role','tab'); $('.slidesjs-stop.slidesjs-navigation').attr('role','tab'); $('.slidesjs-play.slidesjs-navigation').attr('aria-describedby','tip1'); $('.slidesjs-stop.slidesjs-navigation').attr('aria-describedby','tip2'); /* End: This code is added by iTalent as part of iTrack 1859082 */ }); $(document).ready(function() { if($("#slides .item").length < 2 ) { /* Fixing Single Slide click issue (commented following code)*/ // $(".item").css("left","0px"); $(".item.slidesjs-slide").attr('style', 'left:0px !important'); $(".slidesjs-stop.slidesjs-navigation").trigger('click'); $(".slidesjs-previous").css("display", "none"); $(".slidesjs-next").css("display", "none"); } var items_length = $(".item.slidesjs-slide").length; $(".slidesjs-pagination-item > button").attr("aria-setsize",items_length); $(".slidesjs-next, .slidesjs-pagination-item button").attr("tabindex","-1"); $(".slidesjs-pagination-item button").attr("role", "tab"); $(".slidesjs-previous").attr("tabindex","-1"); $(".slidesjs-next").attr("aria-hidden","true"); $(".slidesjs-previous").attr("aria-hidden","true"); $(".slidesjs-next").attr("aria-label","Next"); $(".slidesjs-previous").attr("aria-label","Previous"); //$(".slidesjs-stop.slidesjs-navigation").attr("role","button"); //$(".slidesjs-play.slidesjs-navigation").attr("role","button"); $(".slidesjs-pagination").attr("role","tablist").attr("aria-busy","true"); $("li.slidesjs-pagination-item").attr("role","list"); $(".item.slidesjs-slide").attr("tabindex","-1"); $(".item.slidesjs-slide").attr("aria-label","item"); /*$(".slidesjs-stop.slidesjs-navigation").on('click', function() { var itemNumber = parseInt($('.slidesjs-pagination-item > a.active').attr('data-slidesjs-item')); $($('.item.slidesjs-slide')[itemNumber]).find('.c-call-to-action').attr('tabindex', '0'); });*/ $(".slidesjs-stop.slidesjs-navigation, .slidesjs-pagination-item > button").on('click keydown', function() { $.each($('.item.slidesjs-slide'),function(i,el){ $(el).find('.c-call-to-action').attr('tabindex', '-1'); }); var itemNumber = parseInt($('.slidesjs-pagination-item > button.active').attr('data-slidesjs-item')); $($('.item.slidesjs-slide')[itemNumber]).find('.c-call-to-action').attr('tabindex', '0'); }); $(".slidesjs-play.slidesjs-navigation").on('click', function() { $.each($('.item.slidesjs-slide'),function(i,el){ $(el).find('.c-call-to-action').attr('tabindex', '-1'); }); }); $(".slidesjs-pagination-item button").keyup(function(e){ var keyCode = e.keyCode || e.which; if (keyCode == 9) { e.preventDefault(); $(".slidesjs-stop.slidesjs-navigation").trigger('click').blur(); $("button.active").focus(); } }); $(".slidesjs-play").on("click",function (event) { if (event.handleObj.type === "click") { $(".slidesjs-stop").focus(); } else if(event.handleObj.type === "keydown"){ if (event.which === 13 && $(event.target).hasClass("slidesjs-play")) { $(".slidesjs-stop").focus(); } } }); $(".slidesjs-stop").on("click",function (event) { if (event.handleObj.type === "click") { $(".slidesjs-play").focus(); } else if(event.handleObj.type === "keydown"){ if (event.which === 13 && $(event.target).hasClass("slidesjs-stop")) { $(".slidesjs-play").focus(); } } }); $(".slidesjs-pagination-item").keydown(function(e){ switch (e.which){ case 37: //left arrow key $(".slidesjs-previous.slidesjs-navigation").trigger('click'); e.preventDefault(); break; case 39: //right arrow key $(".slidesjs-next.slidesjs-navigation").trigger('click'); e.preventDefault(); break; default: return; } $(".slidesjs-pagination-item button.active").focus(); }); }); // Start This code is added by iTalent as part of iTrack 1859082 $(document).ready(function(){ $("#tip1").attr("aria-hidden","true").addClass("hidden"); $("#tip2").attr("aria-hidden","true").addClass("hidden"); $(".slidesjs-stop.slidesjs-navigation, .slidesjs-play.slidesjs-navigation").attr('title', ''); $("a#playtitle").focus(function(){ $("#tip1").attr("aria-hidden","false").removeClass("hidden"); }); $("a#playtitle").mouseover(function(){ $("#tip1").attr("aria-hidden","false").removeClass("hidden"); }); $("a#playtitle").blur(function(){ $("#tip1").attr("aria-hidden","true").addClass("hidden"); }); $("a#playtitle").mouseleave(function(){ $("#tip1").attr("aria-hidden","true").addClass("hidden"); }); $("a#play").keydown(function(ev){ if (ev.which ==27) { $("#tip1").attr("aria-hidden","true").addClass("hidden"); ev.preventDefault(); return false; } }); $("a#stoptitle").focus(function(){ $("#tip2").attr("aria-hidden","false").removeClass("hidden"); }); $("a#stoptitle").mouseover(function(){ $("#tip2").attr("aria-hidden","false").removeClass("hidden"); }); $("a#stoptitle").blur(function(){ $("#tip2").attr("aria-hidden","true").addClass("hidden"); }); $("a#stoptitle").mouseleave(function(){ $("#tip2").attr("aria-hidden","true").addClass("hidden"); }); $("a#stoptitle").keydown(function(ev){ if (ev.which ==27) { $("#tip2").attr("aria-hidden","true").addClass("hidden"); ev.preventDefault(); return false; } }); }); // End This code is added by iTalent as part of iTrack 1859082
Top Kudoed Authors