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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
stevemdata
Regular Visitor

IF Statement based on cell values from multiple columns

Currently I have the following measure for calculating 'engagement':

Engagement % = DIVIDE(SUM(DATASET[clicks]),SUM(DATASET [impressions]))

 

DATASET

impressions

clicks

source

Impressionsv2

56

34

web

 

353

23

media

 

53

11

other1

 

353

12

email

34

35

32

social

 

 

However, I now have a new column I need to use for calculating the engagement for email source only. i.e. for email only I need to calculate the clicks against data in another column.

 

i.e. If source = ‘media’ then engagement should be clicks/impressionsv2, otherwise for all other sources it should be calculated as clicks/impressions

1 ACCEPTED SOLUTION

@stevemdata Sorry Replace this part with "email"

Engagement % = 
VAR _prct = 
DIVIDE(
    SUM('DATASET'[clicks]),
   SUM('DATASET'[impressions])
    )
VAR _media_email = CALCULATE( SUM('DATASET'[clicks]), 'DATASET'[source] = "email")
return
IF( SELECTEDVALUE('DATASET'[source]) = "email", DIVIDE( _media_email, CALCULATE( SUM('DATASET'[Impressionsv2]), 'DATASET'[source] = "email")),_prct)




__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

View solution in original post

4 REPLIES 4
DimaMD
Solution Sage
Solution Sage

Hi @stevemdata 
Try it

Engagement % = 
VAR _prct = 
DIVIDE(
    SUM('DATASET'[clicks]),
   SUM('DATASET'[impressions])
    )
VAR _media_email = CALCULATE( SUM('DATASET'[clicks]), 'DATASET'[source] = "media")
return
IF( SELECTEDVALUE('DATASET'[source]) = "media", DIVIDE( _media_email, CALCULATE( SUM('DATASET'[Impressionsv2]), 'DATASET'[source] = "email")),_prct)

Screenshot_32.jpg


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

Hi @DimaMD thank you!

 

Unfortunately I made a mistake in my question above, i meant to say if i.e. If source = ‘email’ then engagement should be clicks/impressionsv2, otherwise for all other sources it should be calculated as clicks/impressions.

 

So in your table the engagement for email row should be 12/34 = 35%

are you able to update your solution please with this in mind? thank you

@stevemdata Sorry Replace this part with "email"

Engagement % = 
VAR _prct = 
DIVIDE(
    SUM('DATASET'[clicks]),
   SUM('DATASET'[impressions])
    )
VAR _media_email = CALCULATE( SUM('DATASET'[clicks]), 'DATASET'[source] = "email")
return
IF( SELECTEDVALUE('DATASET'[source]) = "email", DIVIDE( _media_email, CALCULATE( SUM('DATASET'[Impressionsv2]), 'DATASET'[source] = "email")),_prct)




__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

perfect! thanks

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors