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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

If events are happening at the same time, get the number of events

Hey guys,

I have the following problem. I have a huge table with millions of customers who have different kind of subscriptions (there are like 50+ different subscription types). And what i wanna know, is how many subscriptions they have at the same time at a certain time.

For example this:

CustomerSubscriptionStartEnd
11a1-1-20184-8-2018
22b1-1-20191-1-2020
33c1-1-20181-1-2020
44d1-1-20181-1-2020
11e1-1-20191-1-2020
22f1-4-20251-5-2018
44g1-1-20184-8-2018
44h1-1-20191-1-2020
44i1-1-20181-1-2020
44j1-1-20181-1-2020
44k1-1-20191-1-2020
44l1-4-20251-5-2018

 

And what i would like to know is:

Per customer, per month, number of subscriptions at the same time. 

 

CustomerMonthN at the same time
11january 20181
22january 20181
33january 20181
44january 20183

 

Any ideas? I am stuck at the execution part completely. >_<

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Your data is confusing by some start date> End date. I modified some of them to keep the Start date<End date. then processing the data:

1. Create a calendar table:

Table 2 = CALENDAR(DATE(2018,1,1),DATE(2020,5,1))

2. Add below measure:

Measure = CALCULATE(DISTINCTCOUNT('Table'[Subscription]),FILTER(ALL('Table'),MAX('Table 2'[Date])>=[Start]&&MIN('Table 2'[Date])<=[End]),VALUES('Table'[Customer]))

You'll get the expected results:

02.PNG

 

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

4 REPLIES 4
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Your data is confusing by some start date> End date. I modified some of them to keep the Start date<End date. then processing the data:

1. Create a calendar table:

Table 2 = CALENDAR(DATE(2018,1,1),DATE(2020,5,1))

2. Add below measure:

Measure = CALCULATE(DISTINCTCOUNT('Table'[Subscription]),FILTER(ALL('Table'),MAX('Table 2'[Date])>=[Start]&&MIN('Table 2'[Date])<=[End]),VALUES('Table'[Customer]))

You'll get the expected results:

02.PNG

 

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Insert a Matrix visual with row: customer, column: month, value: subscription count.

Anonymous
Not applicable

Doesn't work like that, they can be both in the same month, but not at the same time (for example one ends on 10th, and the other starts on the 11th).

Anonymous
Not applicable

So you actually need it of a day to day basis?

I may have skipped a few steps, because wheri i mention 'month' you may need to add that trough power query:

Go to edit queries > add column > custom column and use this formula including all brackets:

={Number.From([Start])..Number.From([End])}
Then in the new columnheader click the arrows pointing both ways, and click expand to new rows.

You now have the same table you started with, buth with a single row for each day between start and end.

You should be able to work with that

(before you replied: You do not need each day, so do the following:

Click the new column and click the transform tab > date > month > Start on month.

Now we have a lot of duplicates, al with the first day of the month.

Select ALL of your columns, right click on one and select remove duplicates.

Now rename you 'Custom' column to month. /orginal answer)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.