Forum Discussion
Nees help on the DAX
Dear Community,
Here is the example dataset for my report, there have total 10 condition I need to apply in DAX in order to get the result.
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],
AND(ISBLANK(consignor),consignee<>1),"BLANK",
AND(ISBLANK(consignee),consignor<>1),"BLANK",
consignee=1,Client[Consignee],
consignor=1,Client[Consignor],
"MIX")
return match
I would like to request some help on modify the DAX, for C009 and C010, if the consignee have only one brand name but also having null value, the result is return to the brand name without the null value.
For example,
But if there have more than one brand name with null value, the result will return 'BLANK'
For example,
Here is the pbix: https://ufile.io/l9flqncr
Appreciate any helps provided & thanks for your attention.
NickProp28 , done few changes. If needed you can test by reverting some >= changes
Unique Match Column = var consignee=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber])) var consignor=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber])) var consignee1=CALCULATE(Max(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber])) var consignor1=CALCULATE(Max(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber])) var match=SWITCH(TRUE(), AND(consignor>=1,consignee>=1),consignee1, consignee>=1,consignee1, consignor>=1,consignor1, AND(ISBLANK(consignor),consignee<>1),"BLANK", AND(ISBLANK(consignee),consignor<>1),"BLANK", "MIX") return match
4 Replies
- amitchandak
Super User
NickProp28 , I think moving last two before should help like
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], AND(ISBLANK(consignor),consignee<>1),blank(), AND(ISBLANK(consignee),consignor<>1),blank(), "MIX") return match- NickProp28
Post Partisan
- amitchandak
Super User
NickProp28 , done few changes. If needed you can test by reverting some >= changes
Unique Match Column = var consignee=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber])) var consignor=CALCULATE(DISTINCTCOUNTNOBLANK(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber])) var consignee1=CALCULATE(Max(Client[Consignee]),ALLEXCEPT(Client,Client[ConsolNumber])) var consignor1=CALCULATE(Max(Client[Consignor]),ALLEXCEPT(Client,Client[ConsolNumber])) var match=SWITCH(TRUE(), AND(consignor>=1,consignee>=1),consignee1, consignee>=1,consignee1, consignor>=1,consignor1, AND(ISBLANK(consignor),consignee<>1),"BLANK", AND(ISBLANK(consignee),consignor<>1),"BLANK", "MIX") return match