Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi, I wonder if someone could help me with this issue.
I have the folowing table:
Enterprise_Nbr | LOB (Line_of_business) |
1 | A |
2 | B |
3 | B |
1 | B |
4 | C |
5 | B |
2 | B |
1 | C |
I need to count the number of distinct Enterprise_Nbr which have LOB "A" and "B"
When I use the formula
Solved! Go to Solution.
Hi @YBavré
please try
X =
COUNTROWS (
FILTER (
VALUES ( ENHANCED_CKI_CUSTOMER[Enterprise_Nbr] ),
COUNTROWS (
INTERSECT (
CALCULATETABLE ( VALUES ( ENHANCED_CKI_PRODUCTS[LOB] ) ),
{ "A", "B" }
)
) = 2
)
)
Thanks Tamerj1 for your suggestion,
In this case
ISEMPTY('Table') is more efficient than COUNTROWS because it just requires one attempted read for A and one for B.
Whereas COUNTROWS will have to scan all the records for the context.
Thanks.
Counting the rows of a table of maximum two rows in not significant
Thanks Tamerj1
I dont mind other Super Super offering a better solution but ISEMPTY is the the best practice for cheching if a scenario does or does not exist.
Please dont assume there is just one record per enterprise and teach newbees to use COUNTROWS.
The clue is the command names !
ISEMPTY is a boolean checks if the table expression is empty
where as COUNTROWS is computative.
Please use ISEMPTY for checking and COUNTROWS for computations.
No, if, buts or any excuses ... ISEMPTY is the better solution. OK? 😀😀😀
Try this ...
Thanks for reaching out for help.
I put in a lot of effort to help you, now please quickly help me by giving kudos.
Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button.
One question per ticket please. If you need to extend your request then please raise a new ticket.
You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !
Incidentally, next time please DON'T copy & paste your DAX that does not work and expect us to fathom what you want to do. That is crazy. 😀
Please just give a simple non technical functional decscription of what you want, then let us suggest the DAX. Thank you. 😀😀😀
Hi @speedramps , thank you for trying helping me with this issue. However, it does not seem to be functionning when I aplpy it on my dataset.
I'm totally new on this forum, so I do not know yet all the rules, but I keep your tips in mind.
Hi @YBavré
please try
X =
COUNTROWS (
FILTER (
VALUES ( ENHANCED_CKI_CUSTOMER[Enterprise_Nbr] ),
COUNTROWS (
INTERSECT (
CALCULATETABLE ( VALUES ( ENHANCED_CKI_PRODUCTS[LOB] ) ),
{ "A", "B" }
)
) = 2
)
)
@tamerj1 thnaks a lot: it does the job and I get the resut I was looking for.
Best regards.
@YBavré
As per @speedramps recommendation, the following should perform faster.
X =
COUNTROWS (
FILTER (
VALUES ( ENHANCED_CKI_CUSTOMER[Enterprise_Nbr] ),
ISEMPTY(
EXCEPT (
{ "A", "B" },
CALCULATETABLE ( VALUES ( ENHANCED_CKI_PRODUCTS[LOB] ) )
)
)
)
)
Hi @tamerj1 , I get the error message "a table of multiple values was supplied where a single value was expected" when I run your latest measure...
Yes, that does it, thanks again!
User | Count |
---|---|
50 | |
23 | |
18 | |
18 | |
14 |
User | Count |
---|---|
91 | |
85 | |
46 | |
28 | |
21 |