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

get leaving and new subscriptions per day

Hi all,

 

I have this (simplified) datamodel:

 

IDOpt_InDate
001True01-01-2021
001True02-01-2021
001False03-01-2021
002True02-01-2021
002False03-01-2021
003True04-01-2021

 

Some remarks:

  • This dataset is expanded daily. Every morning, a list of IDs is loaded with their Opt_In state and the date as load date.
  • The Opt_In may change from True to False and back to True (we're talking about newsletter subscriptions, where someone can subscribe, unsubscribe and subscribe again.
  • The first entry of a new ID can be on any date, depending on the date that the ID subscribed. Example: 002 subscribed on 02-01-2021, unsubscribed a day later and subscribed again on 04-01.

What I want to show is the daily variation. So not only the total amount of subscribers (Opt_In = True) per day, but also the variance based on the number of new subscribers on a day and the number of unsubscribers on a day.

And this on a day per day basis 🙂

 

So more or less:

DateTotal subscribersNew subscribersLeaving subscribers
30-06-2021500053
31-06-20215010155

 

where the total subscribers of 31-06 is the total subscribers of 30-06 + new on the 31st and leaving on the 31st.

 

How can I achieve that? Any help is very much appreciated!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Spekko , With sample data I am not able to relate the result

 

Try measures like
new till date = calculate(distinctCOUNT(Table[ID]), filter(all(Table[Date]), Table[Date] <= Max(Table[Date]) && Table[Opt_In] = true())) 
out till date= calculate(distinctCOUNT(Table[ID]), filter(all(Table[Date]), Table[Date] <= Max(Table[Date]) && Table[Opt_In] = false()))

 

remaining till date = [new till date] -[Out till date ]

View solution in original post

6 REPLIES 6
Spekko
Helper I
Helper I

Hi all,

 

After some struggles, I managed to solve this with another approach. With this formula, I can mark the first time a line has been added:

Opt-In FA = if('Table'[opt_in_newsletter]="true",'Table'[scrape_time] = 
	CALCULATE(
		MIN('Table'[scrape_time]), 
		FILTER(ALL('Table'), 'Table'[email]=EARLIER('Table'[email]))
	),false)

 Based on that and variants for opt-outs I can count the number of new subscriptions and leaving subscriptions per day.

 

Thank you for your patience.

v-stephen-msft
Community Support
Community Support

Hi @Spekko ,

 

Can you expand your sample data and show the corresponding expected results based on your sample data?

The text description makes me a little confused.

 

 

 

Best Regards,

Stephen Tao

 

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

amitchandak
Super User
Super User

@Spekko , With sample data I am not able to relate the result

 

Try measures like
new till date = calculate(distinctCOUNT(Table[ID]), filter(all(Table[Date]), Table[Date] <= Max(Table[Date]) && Table[Opt_In] = true())) 
out till date= calculate(distinctCOUNT(Table[ID]), filter(all(Table[Date]), Table[Date] <= Max(Table[Date]) && Table[Opt_In] = false()))

 

remaining till date = [new till date] -[Out till date ]

@amitchandak thank you for taking the time to help. I tried this with my available data-fields, leading to this formula:

 

New-Subscriptions = calculate(distinctCOUNT(Fact_newsletter_contacts[email]), filter(all(Fact_newsletter_contacts[Datekey]), Fact_newsletter_contacts[Datekey] <= Max(Fact_newsletter_contacts[Datekey]) && Fact_newsletter_contacts[opt_in_newsletter] = true()))
 
this throws an error:
A single value for column 'opt_in_newsletter' in table 'Fact_newsletter_contacts' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

Alternatives I tried is "true" instead of true and creating it as a calculated column instead of a measure (based on some content I found online on this matter).

 

I'm sorry: not very tech-savvy and there's no DAX experience within our organisation...

 

@Spekko , is this not a column  opt_in_newsletter ?

 

or this a measure?

@amitchandak Yes, opt_in_newsletter is a column:
newsletter.png

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.