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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
john_Learner
New Member

distinct User ID - count of Distinct Country ID and then the sum of Rank

UidCountry IdRank
U01C0110
U01C0110
U02C0210
U02C0110
U03C0310

Now I need the distinct User ID - count of Distinct Country ID and then the sum of Rank

output is below in a table using DAX

UidCountry IdRank
U01110
U02220
U03110

 

I use distinctcount(countryID) and i am getting distinct count - but struggling to get sum of rank for those distinct count countries.

5 REPLIES 5
tamerj1
Super User
Super User

Hi @john_Learner 
Please refer to attached sample file

1.png2.png

Countries Count = COUNTROWS ( VALUES ( 'Table'[Country Id] ) )
Rank Sum = 
SUMX ( 
    VALUES ( 'Table'[Country Id] ),
    CALCULATE ( MAX ( 'Table'[Rank] ) )
)

 

v-jianboli-msft
Community Support
Community Support

Hi @john_Learner ,

 

Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

john_Learner
New Member

seems ok for this example. when i try to apply the same to new need its failing.

john_Learner
New Member

Any help 

v-jianboli-msft
Community Support
Community Support

Hi @john_Learner ,

 

Please try:

Countryid = DISTINCTCOUNT('Table'[Country Id])

SumRank = 
var _a =DISTINCT('Table')
return SUMX(_a,[Rank])

Final output:

vjianbolimsft_0-1663754444521.png

Best Regards,

Jianbo Li

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

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.