cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
blokesh23
Helper I
Helper I

Custom column to count number of unique occurrences of a key value for a PK column

In PowerQuery I want to add a custom column that provides total number of unique occurences of a key value for a primary key column 

 

For example,  new custom column(Count) should be created based on total number of unique occurences of ID for a certain Key
Below screen shot is what I'm trying to create

 

blokesh23_0-1644262390371.png

 

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

Try this:

 

ID Count per Key = 
CALCULATE(
	DISTINCTCOUNT('TableKeyCountMeasure'[ID]),
	Allexcept('TableKeyCountMeasure', 'TableKeyCountMeasure'[Key])
)
 

 

 

View solution in original post

2 REPLIES 2
sevenhills
Super User
Super User

Try this:

 

ID Count per Key = 
CALCULATE(
	DISTINCTCOUNT('TableKeyCountMeasure'[ID]),
	Allexcept('TableKeyCountMeasure', 'TableKeyCountMeasure'[Key])
)
 

 

 

Thanks for the help, this works as expected

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors