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.
Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.
Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!
User | Count |
---|---|
106 | |
60 | |
45 | |
29 | |
26 |
User | Count |
---|---|
131 | |
94 | |
78 | |
45 | |
41 |