Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Dear Community,
Needs some advice from all of you, all I know is this can be done by using SWITCH
I have these raw data.
Condition is looking for the client (consignee/consignor) which one is unique.
If consignee and consignor both of it is unique, will return Consignee (For example C001, take consignee 'NIKE')
If conignee is unique, ie C002, return 'NIKE' . While C003 consignor is unique,return 'NIKE'
For C004, since there is no unique client. Return the consignor client name.
Expected outcome,
Here is the pbix: https://ufile.io/dizaj4z6
I want to create the new column measure here. Can anyone give me a hints on the dax measure ?
Thanks for the help & attention on this matter
Solved! Go to Solution.
Hi @NickProp28 ,
Create a calculated column like this:
Unique Match Column =
var consignee=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber]))
var consignor=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber]))
var match=SWITCH(TRUE(),
AND(consignor=1,consignee=1),Client[Consignee],
consignee=1,Client[Consignee],
consignor=1,Client[Consignor],
Client[Consignor]
)
return match
or a measure like this to get the desired result:
Unique Match Measure =
var consignee=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber]))
var consignor=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber]))
var match=SWITCH(TRUE(),
AND(consignor=1,consignee=1),FIRSTNONBLANK(Client[Consignee],TRUE()),
consignee=1,FIRSTNONBLANK(Client[Consignee],TRUE()),
consignor=1,FIRSTNONBLANK(Client[Consignor],TRUE()),
FIRSTNONBLANK(Client[Consignor],TRUE())
)
return match
Please accept this as a solution if your question has been answered !!
Appreciate a Kudos 😀
@NickProp28 , the enumeration can be simplified as,
as long as CONSIGNEE is unique, the name of CONSIGNEE is returned; otherwise, CONSIGNOR is returned. So, the formula is also simple enough,
RESULT =
IF (
CALCULATE (
DISTINCTCOUNT ( Client[Consignee] ),
ALLEXCEPT ( Client, Client[ConsolNumber] )
) = 1,
Client[Consignee],
Client[Consignor]
)
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Dear @CNENFRNL ,
Thanks for the code.
What if the condition 4. C004, at the end is taking consignee instead of consignor.
What should I modify on your code?
Hi @NickProp28 ,
Create a calculated column like this:
Unique Match Column =
var consignee=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber]))
var consignor=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber]))
var match=SWITCH(TRUE(),
AND(consignor=1,consignee=1),Client[Consignee],
consignee=1,Client[Consignee],
consignor=1,Client[Consignor],
Client[Consignor]
)
return match
or a measure like this to get the desired result:
Unique Match Measure =
var consignee=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber]))
var consignor=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber]))
var match=SWITCH(TRUE(),
AND(consignor=1,consignee=1),FIRSTNONBLANK(Client[Consignee],TRUE()),
consignee=1,FIRSTNONBLANK(Client[Consignee],TRUE()),
consignor=1,FIRSTNONBLANK(Client[Consignor],TRUE()),
FIRSTNONBLANK(Client[Consignor],TRUE())
)
return match
Please accept this as a solution if your question has been answered !!
Appreciate a Kudos 😀
@NickProp28 , New measure
new measure =
var _1 = calculate(distinctcount([consignee]), filter(allselected(Table), [consolnumber] =max( [consolnumber] )))
var _2 = calculate(distinctcount([consignor]), filter(allselected(Table), [consolnumber] =max( [consolnumber] )))
return
Switch (True () ,
_1 = 1 , max(Table[consignee]),
_2 = 1 ,max(Table[consignor]) ,
max(Table[consignor])
)
or
new column =
var _1 = calculate(distinctcount([consignee]), filter(Table, [consolnumber] =earlier( [consolnumber] )))
var _2 = calculate(distinctcount([consignor]), filter(Table, [consolnumber] =earlier( [consolnumber] )))
return
Switch (True () ,
_1 = 1 , [consignee],
_2 = 1 ,[consignor] ,
[consignor]
)
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!