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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Urgent help - Distinct count of a column in a GroupBy table

Hi All,

I am creating a calculated table where the data is as below. I need to calculate the distinct count of the Order column and perform ranking over it. I have the ranking figured out, but unable to create a table with GroupBy function to calculate the distinct count of the OrderNumber. Is there an alternative approach? Any help is highly appreciated.

Order Count = GROUPBY(Datasource,Datasource[City],Datasource[YEAR],Datasource[OrderType],Datasource[Order no], "Count",Distinct(CURRENTGROUP(), Datasource[Order no])))

 

CityYEARLineTypeOrderTypeOrder no 
Paris2017HPLPPipes400461062
Paris2017HPLPPipes400578517
Paris2017HPLPPipes400663307
Paris2017HPLPPipes100209055
Paris2017HPLPPipes100162131
Paris2017HPLPPipes400604494
Paris2017HPLPPipes400466633
Paris2017HPLPPipes400643457
London2017HPLPPipes400634137
London2017HPLPPipes400455034
London2020HPLPPipes100419496
London2020HPLPPipes100397579
London2020HPLPPipes100436420
London2020HPLPPipes401864588
London2020HPLPPipes401995256
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,

You can try like

new measure

rankx(allselected(Datasource) , calculate(distinctcount(Datasource[Order no])))

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

You can try like

new measure

rankx(allselected(Datasource) , calculate(distinctcount(Datasource[Order no])))

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

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
Anonymous
Not applicable

Thanks @amitchandak , I tried the GroupBy and the measure you sent, calculation works as expected. Thanks for your swift response.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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