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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count of distinct Values inside the column

Hello,

 

 

I have a scenario where i need the distinct value count in a column according to the dates selected in the slicer.

 

Example:

I have used the following DAX measure( count_2) to get the count of distinct item locations according to the dates selected in the slicer.

Ishan25_0-1595849831717.png

But as you can see in the screenshot it shows the count of item location "ZZ"  as 1.

I want it show 2 as it is appearing two times in the output.

 

Here is the date slicer applied:

Ishan25_1-1595850009014.png

 

 

Any help would be much appreciated.

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You get 1 because for ZZ the rows are different. You distinguish them with "last user update." One has SANJAY and the other one IGRAHAM. This is why you see 1.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

You get 1 because for ZZ the rows are different. You distinguish them with "last user update." One has SANJAY and the other one IGRAHAM. This is why you see 1.
mahoneypat
Employee
Employee

The columns you add to your table act as filters.  In your case, that includes the Date and Branch columns.  To remove specific filters, you need to use a variant of the ALL() function (or REMOVEFILTERS()).  To get 2 from your data, I think you will need the following

 

New Count = CALCULATE([count_2], ALL(Table[Branch], Table[Branch Description]), ALLSELECTED('Date'[Date])

 

Note that the Date one uses ALLSELECTED.  That will remove the filter on that column but just in the table (it will keep the filter on the Dates selected in your slicer).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hello @mahoneypat 

 

This is giving me exactly the same as count_2

 

Ishan25_0-1595853021195.png

 

Anonymous
Not applicable

Hello @mahoneypat 

 

I can remove count_2 as this might not be required, i basically need a count of different item locations in the report as per the selected dates.

 

I need to get same the output similar to the filter of item Location in filter pane:

Ishan25_0-1595853299582.png

 

 

 

Hi @Anonymous ,

 

Try if this works

 

LocationsCount =
COUNTROWS (
    FILTER (
        ALL ( ItemLocation[itemlocation] ),
        ItemLocation[itemlocation]
            = MAX ( ItemLocation[itemlocation] )
    )
)

 

Regards,

Harsh Nathani

 

Anonymous
Not applicable

Hi @harshnathani 

 

This does not work:

Ishan25_0-1595854539771.png

The measure count_2 works as expected when i remove all the fields:

Ishan25_2-1595854669379.png

But as soon as i bring branch or any other field it fails to work.

I need to ingore all the other fields as filters .

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors