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
Haidannx
Helper I
Helper I

create new column to distinct count the number of value in each rows

Hi,

I have a data set like below

Request IDProviderPrice
1HMS4$
1TMS7$
1TMS4$
1HMS11$
2TMS1$
2TMS2$
3HMS1$

 

I`d like to create a new column to distinct count "Provider" with the expected outcome like below:

Request IDProviderPriceCount
1HMS4$2
1TMS7$2
1TMS4$2
1HMS11$2
2TMS1$1
2TMS2$1
3HMS1$1

 

Please send help

With many thanks

1 ACCEPTED SOLUTION

Nevermind, i`ve found the DAX useful

# of provider = CALCULATE(DISTINCTCOUNT(table[Provider]),ALLEXCEPT(table,table[request_id]))
 
Thanks for all of your support

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

Create a new column

new column = countx(filter(table,table[Request ID] =table[Request ID] && table[Provider] =table[Provider]),table[Request ID])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

i don`t know why but the result comes out as Blank

It seems like my mistake. missing earlier

new column = countx(filter(table,table[Request ID] =earlier(table[Request ID]) && table[Provider] =earlier(table[Provider])),table[Request ID])

 

Your DAX will tell me the how many rows are there with the same Request ID, not how many Provider does it have with the same Request id =((

can you check again your DAX?

the Provider columns`s  only 2 values whitch are HMS or TMS

 

Capture.PNG

Try

 

Column = CALCULATE(DISTINCTCOUNT(Sheet1[Provider]),FILTER(Sheet1,Sheet1[Request ID]=EARLIER(Sheet1[Request ID])))

 

link :https://www.dropbox.com/s/res6g1hr53edzpn/distinctCount.pbix?dl=0

 

I have known this DAX
However, my dataset is to large (aroun 3 mils row) to use this DAX. It`d dumped RAM

Hi @Haidannx ,

Considering the large amount of data, and creating the calculated column will take up memory, you want to check if there is another method to achieve this requirement (like create one measure) ?

 

Best Regards

Rena

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

Nevermind, i`ve found the DAX useful

# of provider = CALCULATE(DISTINCTCOUNT(table[Provider]),ALLEXCEPT(table,table[request_id]))
 
Thanks for all of your support

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.