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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

New column based on DISTINCTCOUNT + IFS?

Dear community team,

 

I'm trying to get the last column in the table below, given that I have a long list of activites, where some things might be repeated.

 

The feeling is that DISTINCTCOUNT should be somehow involved with maybe CALCULATE + FILTER, but I cannot grasp the idea how exactly I can do that.

 

Any suggestions how to achieve this using DAX / Query Editor?

 

Cheers,

Misha

 

CountryCompanyActivityCost, USDIn which country the company operates?
USAALicense purchase100Both
USABPower BI training150USA
USABTableau uninstall0USA
USACAI / ML training100Both
CanadaANew visuals dev10Both
CanadaDRequest processing5Canada
CanadaCDog walking100Both
1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Anonymous 

Try this for a calc column:

NewCol =
VAR Countries_ =
    CALCULATETABLE (
        DISTINCT ( Table1[Country] ),
        ALLEXCEPT ( Table1, Table1[Company] )
    )
RETURN
    SWITCH ( COUNTROWS ( Countries_ ), 1, Table1[Country], 0, BLANK (), "Both" )

Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

Cheers  Datanaut

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @Anonymous 

Try this for a calc column:

NewCol =
VAR Countries_ =
    CALCULATETABLE (
        DISTINCT ( Table1[Country] ),
        ALLEXCEPT ( Table1, Table1[Company] )
    )
RETURN
    SWITCH ( COUNTROWS ( Countries_ ), 1, Table1[Country], 0, BLANK (), "Both" )

Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

Cheers  Datanaut

Anonymous
Not applicable

Amazing! Many thanks for the quick reply!

 

Cheers,

Misha

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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