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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count the valid items by months

Dear Community,

I am building a data dashboard for a fitness center and I need some help with calculating the valid number of memberships at the end of every month.
I have the dates, when I sold the different yearly or monhly memberships and the dates until these memberships are valid.
How can I calculate how many valid memberships do I have at the end of every month? Thank you in advance!

 

file 

 

2020-01-23_16h01_20.png

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

So, on first glance you need to decide when we count a valid subsciption within a month and when not. There is a valid subscription on 02/06/2019 yet your table shows 0 for 06.2019. What is the border? What if the enddate is 17/06/2019? Does the value change to 1? What if it is 29/06/2019? Still 0 or actually 1? You need to define that boundry.

 

I loaded your data into PowerBI and created a calculated table that has every day for each valid membership in it. Because of the question above and your expected result, I assumed that we won't count the month in which a membership ends. The calculated table is this:

 

GeneratedTable = 
GENERATE('Table',    
    VAR _curStartDate = 'Table'[date sold]
    VAR _curEndDate = EOMONTH('Table'[valid until], -1)
    RETURN
    GENERATESERIES(_curStartDate, _curEndDate))

 

Then I create a measure that counts the distinct memberships:

 

DistinctMembers = DISTINCTCOUNT(GeneratedTable[Member number])

 

Then I created a table visual with DateSold (only Year/Month) and the measure:

image.png

 

PBIX file can be found here: https://1drv.ms/u/s!Ancq8HFZYL_aiItDUonqIklYNkn7Nw?e=SZ73Cx 

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank yor very much for the great solution!

Agnes

JarroVGIT
Resident Rockstar
Resident Rockstar

So, on first glance you need to decide when we count a valid subsciption within a month and when not. There is a valid subscription on 02/06/2019 yet your table shows 0 for 06.2019. What is the border? What if the enddate is 17/06/2019? Does the value change to 1? What if it is 29/06/2019? Still 0 or actually 1? You need to define that boundry.

 

I loaded your data into PowerBI and created a calculated table that has every day for each valid membership in it. Because of the question above and your expected result, I assumed that we won't count the month in which a membership ends. The calculated table is this:

 

GeneratedTable = 
GENERATE('Table',    
    VAR _curStartDate = 'Table'[date sold]
    VAR _curEndDate = EOMONTH('Table'[valid until], -1)
    RETURN
    GENERATESERIES(_curStartDate, _curEndDate))

 

Then I create a measure that counts the distinct memberships:

 

DistinctMembers = DISTINCTCOUNT(GeneratedTable[Member number])

 

Then I created a table visual with DateSold (only Year/Month) and the measure:

image.png

 

PBIX file can be found here: https://1drv.ms/u/s!Ancq8HFZYL_aiItDUonqIklYNkn7Nw?e=SZ73Cx 

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.