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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
NickProp28
Post Partisan
Post Partisan

Need guide on dax measure

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.

NickProp28_0-1615273267559.png

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, 

NickProp28_1-1615273656530.png

 

Here is the pbix: https://ufile.io/dizaj4z6

NickProp28_2-1615273890430.png

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 

 

 

1 ACCEPTED SOLUTION
jaideepnema
Solution Sage
Solution Sage

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
jaideepnema_2-1615276425871.png

 


 

In case you need the file here is the link:
 

Please accept this as a solution if your question has been answered !!

Appreciate a Kudos 😀

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

@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]
)

Screenshot 2021-03-09 085255.png


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?

jaideepnema
Solution Sage
Solution Sage

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
jaideepnema_2-1615276425871.png

 


 

In case you need the file here is the link:
 

Please accept this as a solution if your question has been answered !!

Appreciate a Kudos 😀

amitchandak
Super User
Super User

@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]
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors