Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I have a data set, where an order number can have either one or multiple lines associated with it.
Ex:
OrderNO Type
12345 A
12345 B
12346 A
12347 B
12348 A
12348 B
I want to count all the order numbers that have either Type A or Type B only. I don't want to count Order numbers that have both Type A & Type B
Probably this is quite simple, but I am unable to achieve it.
Thanks in advice.
Kind regards,
Gowtham
=countrows(filter(values(table[order no]),calculate(distinctcount(table[type]))=1))
Hi Daniel,
This formula is not working for me, I need to measure count for rows that has Type A only(which is one in the sample data). Same for Type B.
Kind regards,
Gowtham
HI @GomzeeR ,
You can use below code:-
Unique_count =
COUNTROWS (
SUMMARIZE ( 'Table (2)', 'Table (2)'[OrderNO ], 'Table (2)'[Type] )
)
Below would be output
Hope you wanted the same output if not please share the expected output.
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi Samarth,
Thanks for taking time to help me.
If I add another Order No that has only Type A, my expected output should be.
TypeA - 2
TypeB - 1
Your suggested formula still shows, TypeA - 1 and TypeB - 2.
I want to display order numbers that have Only Type A or only Type B. I don't want to count Order numbers that have Both.
Hope you understood my expected output.
Hi Samarth,
Thanks for your reply.
I want a count for Type A to be 1 and Type B to be 1(From the example data).
Count of Type A(unique) = 1
Count of Type B(Unique) = 1
I want to count only rows that has either A or B not both.
Kind regards,
Gowtham
Hi @GomzeeR
You can try below code it will help
Unique_count =
COUNTROWS (
FILTER (
VALUES ( 'Table (2)'[Type] ),
CALCULATE ( DISTINCTCOUNT ( 'Table (2)'[OrderNO ] ) > 1 )
)
)
Output:-
Thanks
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |