Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello Everyone
I need to create a Calculated Column to flag my company's clients.
Algorithm is simple but tricky:
ClientId | Provider | Flag |
Jhon | MyCompany | SharedClient |
Jhon | Provider02 | SharedClient |
Jhon | Provider17 | SharedClient |
Luis | Provider11 | NotMyClient |
Luis | Provider03 | NotMyClient |
Carlos | MyCompany | ExclusiveClient |
Pedro | Provider16 | SharedClient |
Pedro | MyCompany | SharedClient |
Last but not least, I cant use row count because we have the same information for all months of the year in the same table
Any suggestions about how to create the Calculated Column.
Rewards.
Solved! Go to Solution.
@AvalBuroAdmin That's why I used SUMMARIZE.
@AvalBuroAdmin , As a new column
new column =
var _mycomp = countx(filter(Table,[ClientId] =earlier([ClientId]) && [Provider] ="MyCompany"),[ClientId])+0
var _ocomp = countx(filter(Table,[ClientId] =earlier([ClientId]) && [Provider] <> "MyCompany"),[ClientId])+0
return
Switch() ( True() ,
_mycomp>0 && _ocomp =0 , "ExclusiveClient",
_mycomp>0 && _ocomp >0 ,"SharedClient",
"NotMyClient"
)
@AvalBuroAdmin - Maybe:
Flag =
VAR __Table = SELECTCOLUMNS(SUMMARIZE(FILTER('Table',[ClientId]=EARLIER([ClientId])),[Provider]),"Count",COUNTROWS('Table'),"Provider",[Provider])
RETURN
SWITCH(
COUNTROWS(__Table)=1 && "MyCompany" IN DISTINCT(__Table),"ExclusiveClient",
"MyCompany" IN DISTINCT(__Table),"SharedClient",
"NotMyClient"
)
@Greg_Decklerthe problem is I can have more than 1 row with the same client and provider because in the same table same data is detailed for every month of the year (and others columns). Is there a way to create the flag without counting rows or calcluate this column in power query editor?
@AvalBuroAdmin That's why I used SUMMARIZE.
User | Count |
---|---|
16 | |
13 | |
12 | |
12 | |
11 |
User | Count |
---|---|
19 | |
16 | |
15 | |
11 | |
9 |