Forum Discussion

romovaro's avatar
romovaro
Icon for Responsive Resident rankResponsive Resident
4 years ago
Solved

Dax formula comparing 2 columns

Hello

 

I have the Below table:

 

NameProject Manager / CoordinatorImplementation ConsultantRegional PMCountry Long NameCIDCUID
Client ADorottya Fernabdez  FranceNCPFNCPFFR01
Client BJohn SMith John SMithFranceASPNASPNFR01
Client BJohn SMith John SMithGermanyASPNASPNDE01
Client BJohn SMith John SMithKorea, Republic ofASPNASPNKR01
Client BJohn SMith John SMithMalaysiaASPNASPNMY01
Client BJohn SMith  RussiaASPNASPNRU01
Client B   SpainASPNASPNES01
Client BJohn SMith Ryan HughesChinaASPNASPNCN01
Client BJohn SMith  ChinaASPNASPNCN02
Client BJohn SMith  IndiaASPNASPNIN01
Client BJohn SMith Ryan HughesItalyASPNASPNIT01
Client BJohn SMith  JapanASPNASPNJP01
Client BJohn SMith  SingaporeASPNASPNSG01
Client BJodi Forester Dorottya FernabdezBelgiumASPNASPNBE02
Client CJodi Forester  Oman10000622158
Client CJodi Forester  Poland10000632159
Client CJodi Forester  Saudi Arabia10000642161
Client CJodi Forester  South Africa10000652163
Client CJohn SMith  Sweden10000662164
Client CJodi Forester  United Arab Emirates10000672167
Client D   ThailandTNSGTNSGTH01

 

I can have diff scenarios.

 

Scenario 1: Name in the  Project Manager / Coordinator column is EQUAL to Name in Regional PM column.

Scenario 2: Name in the Project Manager/Coordinator column but BLANK in the Regional PM column or viceversa. 

Scenario 3: Name in the Project Manager/Coordinator column and different Name in the Regional PM column.

Scenario 4: Name in the Regional PM column column and different Name in the Project Manager/Coordinator column.

Scenario 5: Both columns are BLANK

 

I would like to create custom formulas for every scenario using the CUID column (unique customer number) as filter.

 

Scenario 1 example: Name in the  Project Manager / Coordinator column is EQUAL to Name in Regional PM column and columns are not blank. Tried to create formula but it's not working.

 

Scenario 1 =
var tab =
CALCULATETABLE (
VALUES ( PVCEL[CUID]),
FILTER (
PVCEL,
PVCEL[Project Manager / Coordinator] = PVCEL[Regional PM]
)
)
return
CALCULATE (
COUNT ( PVCEL[CUID] ),
INTERSECT ( VALUES(PVCEL[CUID] ), tab ),
FILTER (
PVCEL,
&& PVCEL[Regional PM] <> BLANK ()
)
)

 

and the idea is to create similar formulas with the diff scenarios. Any help? thanks

 

 

 

  • Hi romovaro ,

     

    Hope I understand correctly. Please try to create the following measures:

    S1 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Project Manager / Coordinator]='Table'[Regional PM]&&'Table'[Project Manager / Coordinator]<>""))
    
    S2 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Regional PM]=""&&'Table'[Project Manager / Coordinator]<>""))
    
    S3 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Regional PM]<>'Table'[Project Manager / Coordinator]&&'Table'[Regional PM]<>""))
    
    S4 the same as S3
    
    S5 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Regional PM]=""&&'Table'[Project Manager / Coordinator]=""))

     


    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • V-lianl-msft's avatar
    V-lianl-msft
    Icon for Community Support rankCommunity Support

    Hi romovaro ,

     

    Hope I understand correctly. Please try to create the following measures:

    S1 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Project Manager / Coordinator]='Table'[Regional PM]&&'Table'[Project Manager / Coordinator]<>""))
    
    S2 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Regional PM]=""&&'Table'[Project Manager / Coordinator]<>""))
    
    S3 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Regional PM]<>'Table'[Project Manager / Coordinator]&&'Table'[Regional PM]<>""))
    
    S4 the same as S3
    
    S5 = CALCULATE(COUNT('Table'[CUID]),FILTER('Table','Table'[Regional PM]=""&&'Table'[Project Manager / Coordinator]=""))

     


    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • romovaro's avatar
      romovaro
      Icon for Responsive Resident rankResponsive Resident

      Awesome Liang. It works. Thank you so much