Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I need to implement the below logic in DAX
If Direction = Inbound then COUNT DISTINCT (GS_SENDER_ID) else If Direction = Outbound then COUNT DISTINCT (GS_RECEIVER_ID)
and I have written the below code for first condition:
Partner Count = CALCULATE(DISTINCTCOUNT(Test[GS_SENDER_ID]), Test[Direction] = "I") , but how can I implement the 2nd condition here?
else If Direction = Outbound then COUNT DISTINCT (GS_RECEIVER_ID)
Hey,
maybe it is as simple as @PattemManohar already mentioned or it is much more complex.
I'm assuming that your dataset is about some kind of shipments and one shipment is either inbound (I) or outbund (O).
Now if you filter this dataset may contain rows that are eihter I or O, but nevertheless you need to know the number of distinct partners that have been engaged with the shipment.
I'm wondering if a partner can be either SENDER or RECEIVER depending on the direction of the shipment? And if this may be the case, if the same ID is used, and if you want a partner to be counted once no matter of the role the partner is playing?
Maybe you might consider to provide some sample data, upload the pbix to onedrive or dropbox and share the link.
Somehow, I'm hoping that the complexity of your question is of the latter 🙂 This will be fun.
Regards,
Tom
@Anonymous Please try this..
CountResult = VAR _InboundCount = CALCULATE(DISTINCTCOUNT(Test[GS_SENDER_ID]),Test[Direction]="I") VAR _OutboundCount = CALCULATE(DISTINCTCOUNT(Test[GS_RECEIVER_ID]),Test[Direction]="O") RETURN IF(Test[Direction]="I",_InboundCount,_OutboundCount)
Proud to be a PBI Community Champion
Hi,
I have used your expression and it gives me a error like below screen shot:
Hi @Anonymous,
Add a MIN if that formula is the solution.
if(MIN('Test'[Direction]) = "I",
Best Regards,
Dale
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |