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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Krunalbpatel
Helper III
Helper III

Distinct Count based on multiple column

Hi,

 

I want to display value which is as described below.

My calculation is like this

 

var a =Distinct count of value 1

var b= Count of Value 2

var ans=b/a

 

I want to display ans as my result.

 

But Problem is there I have multiple records for all records. That means for value 1 (distinct) I got multiple values. So my calculation is not properly set as my requirement. So please help me in this case. If Found Unique count that is based on multiple column(value 1 and value 2) for var b.

 

Thanks.

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Krunalbpatel,

Please change the formula of var b to the following formula:

var b = COUNTROWS(
 SUMMARIZE(Table,Table[Name],Table[Value1],Table[Value2])
)


I create a table visual to display your expected result. For more details, you can review the example in this attached PBIX file:https://1drv.ms/u/s!AhsotbnGu1NogXByWhS2F551DemE.

3.PNG

Thanks,
Lydia Zhang

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

View solution in original post

6 REPLIES 6
BhaveshPatel
Community Champion
Community Champion

Hi Krunal,

 

Happy to help you with this. Please provide a snapshot of data and what are you trying to achieve.

 

Regards

Bhavesh

 

 

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Hi,

 

I have data like this

Id Name Value1 Value2

1 abc      1          1

2 abc      1          2

3 abc      1          3

4 pqr      2         1

5 pqr      2         2

6 abc      1          1

7 abc      1          2

8 mnq    3          1

9 pqr      2         1

10 xyz    4         2

 

Now my calculation is like this

var a = DISTINCTCOUNT(value1)

var b = COUNT(Value2)

 

My result wold give me like

abc 1 - 5

pqr  1 - 3

mnq 1 - 1

xyz   1 - 1

 

But I need

abc 1 - 3

pqr  1 - 2

mnq 1 - 1

xyz   1 - 1

 

For this I need to count distinct on multiple column so

1 abc      1          1

6 abc      1          1

this will result only 1

 

Thanks And Regards

Krunal Patel

 

Hi @Krunalbpatel,

Please change the formula of var b to the following formula:

var b = COUNTROWS(
 SUMMARIZE(Table,Table[Name],Table[Value1],Table[Value2])
)


I create a table visual to display your expected result. For more details, you can review the example in this attached PBIX file:https://1drv.ms/u/s!AhsotbnGu1NogXByWhS2F551DemE.

3.PNG

Thanks,
Lydia Zhang

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

Hi Lydia Zhang,

 

Thank you for your reply. I got my solution and its works fine for me.

 

Thanks and Regards,

Krunal Patel

Hi Krunalbpatel,

 

Test= SUMX(DISTINCT('Table'[Value2]),CALCULATE( VALUES('Table' [Value2])))

 

I hope this helps,

Christian

Hi cosborn1231,

 

No This will not help me. In this case I got the sum of distinct values but I want the distinct value count against value 1.

 

Thanks and Regards,

Krunal Patel

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors