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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Oscar_Mtz_V
Kudo Commander
Kudo Commander

Distinct count of only the minimum value

This is my data table:

Support.pbix

Screenshot 2022-05-05 172827.pngI need to have a disctinc count of employees IDs but only count when the instance where they appear is less than or equal to three, and only count the minor instance. 
For example, when I click on "Name 5," I only need to see a count in number 1 (green) and nothing on the 2 (red). 

Screenshot 2022-05-05 180652.pngI've a partial working DAX, which already makes the function on only counting the distinct ID of instances less than or equal to three. But the second condition is missing.

DCount IDs of grade >3 = 
CALCULATE(
DISTINCTCOUNT('Append'[Employee ID]),
FILTER(
'Append',
'Append'[Standard Value] <= 3
)

)
1 ACCEPTED SOLUTION

@amitchandak , your response although not the solution, guided me through the right path.
The key here was the VAR selValue which applied the correct context when used in a Matrix and replaced the SUM for a MIN.

 

Also, I didn't hard code the value "3", in its place I used a parameter. 

 

Here is the final DAX that did the trick:

DCount GUID min with parameter = 
VAR selValue = SELECTEDVALUE('Append'[Standard Value])
VAR Calc= 
    COUNTX(
        FILTER(
            SUMMARIZE(
                ALLSELECTED('Append'),
                'Append'[Employee GUID],
                'Append'[UniqueID],
                "Min", MIN('Append'[Standard Value])
            ),
            [Min] <= [Parameter Value] &&
            [Min] = selValue
        ),
        [Employee GUID]
    )
RETURN
Calc

 

View solution in original post

6 REPLIES 6
v-jayw-msft
Community Support
Community Support

Hi @Oscar_Mtz_V ,

 

Here the selection is sum of instance.

vjaywmsft_0-1652680316087.png

It should be correct that the corresponding data in the table is 2.

If you want to show the distinct count, please select count(distinct).

If I misunderstood your meaning, please share more details.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

@v-jayw-msft , it is a bit more complex than that, please see the thread of responses where the issue is explained. 

amitchandak
Super User
Super User

@Oscar_Mtz_V , Try a measure like

Countx(Filter(summarize(Table, Table[Employee Name], Table[Standard Value], "_1", sum(Table[Value])), [_1] <3), [Employee Name])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak , your response although not the solution, guided me through the right path.
The key here was the VAR selValue which applied the correct context when used in a Matrix and replaced the SUM for a MIN.

 

Also, I didn't hard code the value "3", in its place I used a parameter. 

 

Here is the final DAX that did the trick:

DCount GUID min with parameter = 
VAR selValue = SELECTEDVALUE('Append'[Standard Value])
VAR Calc= 
    COUNTX(
        FILTER(
            SUMMARIZE(
                ALLSELECTED('Append'),
                'Append'[Employee GUID],
                'Append'[UniqueID],
                "Min", MIN('Append'[Standard Value])
            ),
            [Min] <= [Parameter Value] &&
            [Min] = selValue
        ),
        [Employee GUID]
    )
RETURN
Calc

 

@Oscar_Mtz_V ,

Kudos to you !!

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak , thanks for your message, the propossed DAX is still not showing the desired results. 

When I click on "Name 5" on the above table, this should only count the number 1

Oscar_Mtz_V_0-1651815431019.png

Via DAX Studio I looked into the craeted table, and this shoulb ignore the "Name 5" with value 2. 

Oscar_Mtz_V_1-1651815542230.png

I then tried to use the minimun:

Oscar_Mtz_V_3-1651815904775.png

but it is not working either. As when I select "Name 5" the employee keep showin "1" count in both values. 

Oscar_Mtz_V_2-1651815862935.png

There is something in the row context of the visual affecting the result, as in DAX studio, the table iscorrect with the MIN.

Oscar_Mtz_V_4-1651816180342.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.