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
FVZ
Frequent Visitor

DistinctCount ONLY the lowest values of a column in case of multiple rows

I'm looking for a DAX calculation which does DISTINCTCOUNT with a certain condition. If a Customer has two different Priorities, it should only do a count on the lowest Priority. To demonstrate with dummy data:

 

Customer Priority

Jan5
Jan1
Tom2
Dirk6

 

You see that Customer Jan has two rows, one with Priority 5 and 1. In this case I want to DISTINCTCOUNT the Customer only for the lowest Priority, being 1 in this case. The end result should look as follows. 

 

FVZ_0-1733234693887.png

 

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @FVZ 

 

Thank you very much FreemanZ and dharmendars007 for your prompt reply.

 

Try this:

 

Create measures.

 

Lowest Priority = 
CALCULATE(
    MIN('Table'[Priority]),
    ALLEXCEPT('Table', 'Table'[Customer])
)

 

Distinct Customer Count = 
CALCULATE(
    DISTINCTCOUNT('Table'[Customer]),
    FILTER(
        'Table',
        'Table'[Priority] = 'Table'[Lowest Priority]
    )
)

 

Here is the result.

 

vnuocmsft_0-1733293501023.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

5 REPLIES 5
dharmendars007
Super User
Super User

Hello @FVZ , 

Please try the below measure to count customers for lowest priority.

Lowest Priority Customer Count =
COUNTROWS(
SUMMARIZE('YourTable','YourTable'[Customer],"LowestPriority",
                      MIN('YourTable'[Priority]))

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 





It works to a certain extend, but only as a total. If I put the Priority column on the axis, I still see it counting double. Any advice/adjustments on the code? Would appreciate it!

FVZ_1-1733237873188.png

 

 

FreemanZ
Super User
Super User

hi @FVZ ,

 

try like:

measure =

VAR _table =

ADDCOLUMNS(

    VALUES(data[Customer]),

     "LowestPriority",

      CALCULATE(MIN(data[Priority])

)

VAR _result =

CALCULATE(

   DISTINCTCOUNT(data[Customer]),

   TREATAS(

      _table,

      data[Customer],

       data[Priority]

    )

)

RETURN _result

 

FVZ
Frequent Visitor

It works to a certain extend, but only as a total. If I put the Priority column on the axis, I still see it counting double. Any advice/adjustments on the code? Would appreciate it!

FVZ_2-1733237896077.png

 

 

Anonymous
Not applicable

Hi @FVZ 

 

Thank you very much FreemanZ and dharmendars007 for your prompt reply.

 

Try this:

 

Create measures.

 

Lowest Priority = 
CALCULATE(
    MIN('Table'[Priority]),
    ALLEXCEPT('Table', 'Table'[Customer])
)

 

Distinct Customer Count = 
CALCULATE(
    DISTINCTCOUNT('Table'[Customer]),
    FILTER(
        'Table',
        'Table'[Priority] = 'Table'[Lowest Priority]
    )
)

 

Here is the result.

 

vnuocmsft_0-1733293501023.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.

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Users online (25)