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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Previous month totals by Subcategory

IHi All, 

Im trying to get the previous month totals . I have used the following  dax

Credentials Added Previous Month =
VAR startdate = EOMONTH(TODAY(),-2)+1
var enddate = EOMONTH(TODAY(),-1)
RETURN
CALCULATE(
COUNT(fact_cred_milestones[customer_bp]),
FILTER(ALL(fact_cred_milestones),fact_cred_milestones[milestone_date]>= startdate
&& fact_cred_milestones[milestone_date]<= enddate),fact_cred_milestones[milestone_type]="CA" )
 
This gives me the counts for 'CA' 
However ,In a different visual I need to show the counts of CA split into subcatgories that are part of 'CA' . Rite now the same CA count is shown for all subcategories under CA. Any help ? pm.png
1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Change the ALL in your FILTER from ALL(fact_cred_milestones) to

ALL(fact_cred_milestones[milestone_date], fact_cred_milestones[milestone_type])

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Anonymous change to this:

 

Credentials Added Previous Month =
VAR startdate = EOMONTH(TODAY(),-2)+1
var enddate = EOMONTH(TODAY(),-1)
RETURN
CALCULATE(
COUNT(fact_cred_milestones[customer_bp]),
FILTER(ALL(fact_cred_milestones),fact_cred_milestones[milestone_date]>= startdate
&& fact_cred_milestones[milestone_date]<= enddate),
KEEPFILTERS(fact_cred_milestones[milestone_type]="CA" )
 )

 

BTW, when you are working with the data, the best practice is to add a date dimension and use that for any time intelligence-based calculations. It will be much faster and you will develop a more scalable solution. You can add a date dimension in your model by following my blog post here  Create a basic Date table in your data model for Time Intelligence calculations | PeryTUS IT Solutio...

 

Follow us on LinkedIn And subscribe to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

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.

mahoneypat
Microsoft Employee
Microsoft Employee

Change the ALL in your FILTER from ALL(fact_cred_milestones) to

ALL(fact_cred_milestones[milestone_date], fact_cred_milestones[milestone_type])

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat Thanks!!! It worked

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.