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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
AvalBuroAdmin
Regular Visitor

Create a Flag calculated Column for MyCompany clients

Hello Everyone

 

I need to create a Calculated Column to flag my company's clients.

Algorithm is simple but tricky:

  • If a Client only has MyCompany as provider it should be marked as ExclusiveClient
  • If a Client has MyCompany and any other company as providers should me marked as SharedClient
  • Finally if the client doesnt have MyCompany as provider it should be marked as NotMyClient
ClientIdProviderFlag
JhonMyCompanySharedClient
JhonProvider02SharedClient
JhonProvider17SharedClient
LuisProvider11NotMyClient
LuisProvider03NotMyClient
CarlosMyCompanyExclusiveClient
PedroProvider16SharedClient
PedroMyCompanySharedClient

 

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.

1 ACCEPTED SOLUTION

@AvalBuroAdmin That's why I used SUMMARIZE.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Super User
Super User

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


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@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.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.