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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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

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

 

 

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

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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