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
Vtomsons
Helper I
Helper I

Column IF Statement with two variables help

Hi,

 

I am trying to calculate the value of all course registrations that occured after a special promotion price course to determine if a promotional campaign yielded adequate revenue and am coming across a summation issue. Hope someone can suggest a way to get around it.

 

I would like to count all the registrations that occur after a promotion course was completed so decided to use the course "registration start date" as the key indicator to count if it occurs after the promo course. Issue is I have more then one promo course per student so the equation below works but it doubles or triples the course count when the criteria is met so the sum is off (which I then use to calculate a dollar amount).

 

Here's the new column I created: 

Promo Next Course Amount =
IF([Registration Type]="Promo" && [Registration Status]="Completed",
var s = [Student ID]
var rt = [Registration Type]
var cn = [Offerings Name]
var sd = [Registration start date]
var r = calculate(COUNTROWS('ONLINE Reg''n'),ALL('ONLINE Reg''n'),'ONLINE Reg''n'[Student ID]=s,'ONLINE Reg''n'[Registration Type]<>"Promo",'ONLINE Reg''n'[Registration start date]>sd)
return r)

 

This equation works perfect when there is only one promo course. But when there are multiple promo courses, my next equation summarizes all from this column and makes the final number alot higher then it actually is. 

Promo Revenue = 'ONLINE Reg''n'[Course Cost]*'ONLINE Reg''n'[Promo Next Course Amount]

 

I was hoping I could only count the most recent promo course (based on registration start date) to avoid this summary issue.

 

Here's an example that calculates 4X more then I want it to. 

 

ContactCourses NameRegistration StatusRegistration start dateRegistration TypeCourse costPromo Next course AmountPromo Revenue
Liban FarahCOHS 3110Completed10/01/2022 595  
Liban FarahCOHS 3120Completed14/02/2022Promo59563570
Liban FarahCOHS 3130Completed07/04/2022Promo59563570
Liban FarahCOHS 3210Completed14/04/2022Promo59563570
Liban FarahCOHS 3220Completed19/04/2022Promo59563570
Liban FarahCOHS 3230Completed21/04/2022 595  
Liban FarahCOHS 3310Completed28/04/2022 595  
Liban FarahCOHS 3320Completed28/04/2022 595  
Liban FarahCOHS 3330Completed28/04/2022 595  
Liban FarahCOHS 3340Completed28/04/2022 595  
Liban FarahCOHS 3410Completed28/04/2022 595  
Total     2414280

 

Yes the student registered for 6 courses with a registration start date greater then the new start date but this result below is what I hope someone could get me towards. Only return for the most recent course with a Promo rwegistration type. Thanks for any help

 

ContactCourses NameRegistration StatusRegistration start dateRegistration TypeCourse costPromo Next course AmountPromo Revenue
Liban FarahCOHS 3110Completed10/01/2022 595  
Liban FarahCOHS 3120Completed14/02/2022Promo595  
Liban FarahCOHS 3130Completed07/04/2022Promo595  
Liban FarahCOHS 3210Completed14/04/2022Promo595  
Liban FarahCOHS 3220Completed19/04/2022Promo59563570
Liban FarahCOHS 3230Completed21/04/2022 595  
Liban FarahCOHS 3310Completed28/04/2022 595  
Liban FarahCOHS 3320Completed28/04/2022 595  
Liban FarahCOHS 3330Completed28/04/2022 595  
Liban FarahCOHS 3340Completed28/04/2022 595  
Liban FarahCOHS 3410Completed28/04/2022 595  
Total     63570
1 ACCEPTED SOLUTION
2 REPLIES 2

Thank you Amit. I think I almost have it using the two measures on your blog. One scenario is not working though. If the latest registration start date is the same for multiple promo courses, the sum is calculating all three rather then just the one. The measure works but my data for some have the same registration start date for the latest promo course, ugh. Any ideas on how to account for this in one of these measures from your blog? Thanks again!

 

Last Promo Date Qty =
var _max = MAXX(FILTER(ALLSELECTED('ONLINE Reg''n'), 'ONLINE Reg''n'[Student ID] = MAX('ONLINE Reg''n'[Student ID])), 'ONLINE Reg''n'[Registration start date])
return CALCULATE(SUM('ONLINE Reg''n'[Promo Revenue]),FILTER('ONLINE Reg''n','ONLINE Reg''n'[Student ID]=MAX('ONLINE Reg''n'[Student ID]) && ('ONLINE Reg''n'[Registration start date] = _max)))

 

Promo Revenue SUM = SUMX(VALUES('ONLINE Reg''n'[Student ID]), 'ONLINE Reg''n'[Last Promo Date Qty])

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.