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
jak8282
Helper III
Helper III

Using the logic for calculated column in ameasure

Hi, 

 

I have the following code

 

 

Count = 
IF (
   CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[First Name] ), "dummy" ) ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[First Name] ), "regression" ) ||
    LEFT ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[First Name] ), 4 ) = "test" ||
    RIGHT ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[First Name] ), 4 ) = "test" ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[First Name] ), "condition" ) ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[First Name] ), "invalid" ) ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Full Name]), "dummy" ) ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Full Name] ), "regression" ) ||
    LEFT ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Full Name] ), 4 ) = "test" ||
    RIGHT ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Full Name] ), 4 ) = "test" ||
    CONTAINSSTRING ( 'FINLIVE - Contact Details (Email & Phone)'[Full Name], "condition" ) ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Full Name] ), "invalid" ) ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Email Address] ), "dummy" ) ||
    CONTAINSSTRING ( LOWER ('FINLIVE - Contact Details (Email & Phone)'[Email Address] ), "regression" ) ||
    LEFT ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Email Address]  ), 4 ) = "test" ||
    RIGHT ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Email Address]  ), 4 ) = "test" ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Email Address] ), "condition" ) ||
    CONTAINSSTRING ( LOWER ( 'FINLIVE - Contact Details (Email & Phone)'[Email Address]  ), "invalid") ,
    "Test Records",
    "Clients"
)

 

You cant really have Column references in a measure without some aggregation.  How coulkd I use this code in a measure?

 

Thanks

1 ACCEPTED SOLUTION
poweringthru
Helper I
Helper I

You could have it as a calculated column on the table (since I'm only seeing reference to that one table 'FINLIVE - Contact Details (Email & Phone)', and then have your measures be:

Total Test Records =
CALCULATE(
    COUNTROWS('FINLIVE - Contact Details (Email & Phone)'),
    'FINLIVE - Contact Details (Email & Phone)'[Count] = "Test Records"
)

And:

Total Clients =
CALCULATE(
    COUNTROWS('FINLIVE - Contact Details (Email & Phone)'),
    'FINLIVE - Contact Details (Email & Phone)'[Count] = "Clients"
)

 

View solution in original post

1 REPLY 1
poweringthru
Helper I
Helper I

You could have it as a calculated column on the table (since I'm only seeing reference to that one table 'FINLIVE - Contact Details (Email & Phone)', and then have your measures be:

Total Test Records =
CALCULATE(
    COUNTROWS('FINLIVE - Contact Details (Email & Phone)'),
    'FINLIVE - Contact Details (Email & Phone)'[Count] = "Test Records"
)

And:

Total Clients =
CALCULATE(
    COUNTROWS('FINLIVE - Contact Details (Email & Phone)'),
    'FINLIVE - Contact Details (Email & Phone)'[Count] = "Clients"
)

 

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.