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
Anonymous
Not applicable

Number Active between two dates

I have data that comes in similiar to this: 

 

Customer IDCustomer TypeWeekActive
AType 111
AType 121
BType 111
CType 221
DType 111
DType 121
EType 111
EType 121
FType 111
FType 121

 

The active column is calculated at the ETL level and either has a 1 or a 0.  I am specifically wanting to know the number of customers who were active in Week 1 AND Week 2. Please note that the dates could change so I do not want to hardcode the dates.  I have gotten close but can’t quite get it to function for me.  

 

If I pivot the data, you can see that four customers ( A, D, E, F) were active in those two weeks.  

 

Sum of ActiveColumn Labels  
Weeks12Grand Total
A112
B1 1
C 11
D112
E112
F112
Grand Total5510

 

I can't use where the sum is two because you can have decimal values come in.  So I am looking for counts.. Would love help on this. 

11 REPLIES 11
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Could you pls show me what output you want ,not very clear.

 

Best Regards

Lucien

parry2k
Super User
Super User

@Anonymous Good luck Do share your findings once it works. Cheers!!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous I have no idea what you mean. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

I got it to work with just a flat Excel file.  Still trying to get it to work in my data model.  

parry2k
Super User
Super User

@Anonymous here is the measure that will get you the count of active customers:

 

Total Active Customers = 
VAR __totalWeeks = CALCULATE ( COUNTROWS ( VALUES ( Active[Week] ) ), ALLSELECTED () )
RETURN 
SUMX ( 
    VALUES ( Active[Customer ID] ), 
    VAR __active = CALCULATE ( COUNTROWS ( Active ), Active[Active] = 1, Active[Week] )
    RETURN IF ( __active >= __totalWeeks, 1 ) 
)

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Seems close but didn't quite get me to what I was expecting with my dataset.  I was expecting a value in the 20 range and got 800,000.

 

This gives me 2, which is the correct number of weeks I have selected: 

CALCULATE ( COUNTROWS ( VALUES ( Active[Week] ) ), ALLSELECTED () )

 

If I add my detail back in, the measure gives me 33 which is the number of customer ID's displaying.

parry2k
Super User
Super User

@Anonymous to add further that screen shot is from Power BI



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous ofcourse, this is a power bi forum. my question again, is that the output you are looking for?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

The ultimate output would result in just the number 4.  I have a measure that calculates the total number of customers in both weeks (6).  I will be using that measure to show number active (4) / total customers (6) = 67%

parry2k
Super User
Super User

@Anonymous is this what you are looking for?

 

parry2k_0-1629327139223.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

I should clarify that I am trying to solve this in Power BI.  I know how to do this in Excel and SQL But not PBI.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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