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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Pawel_1990
Helper I
Helper I

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.