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
shareezsaleem
Helper III
Helper III

Multiple months selected, consider the oldest

Hi Team,

 

I have below formula:

Count Of Contracts = SWITCH(TRUE(),VALUEs(Contracts_Details[Status_Revised])="Beginning",CALCULATE(DISTINCTCOUNT(Contracts_Details[Contract Ref.]),filter('Calendar','Calendar'[Month Name]="Jan")),VALUES(Contracts_Details[Status_Revised])="Expired" || Values(Contracts_Details[Status_Revised])="Expired On Last Day",-1*DISTINCTCOUNT(Contracts_Details[Contract Ref.]),DISTINCTCOUNT(Contracts_Details[Contract Ref.]))
 
I need to replace the Jan (highlighted) with below but it doesn't work as it filter all months selected.
Multiple Selection_Month = LEFT(CONCATENATEX(VALUES('Calendar'[Month Name]),'Calendar'[Month Name],","),3)
 
Basically, what I am looking is to count the contract numbers based on month & year selection. If I select multiple months, for e.g. Feb & Mar- I need to count only contracts created in Feb.
1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

@shareezsaleem 

do you also have a numeric month column?

Then it would look like this.

CALCULATE(DISTINCTCOUNT(Contracts_Details[Contract Ref.]),filter('Calendar','Calendar'[Month No]=MIN('Calendar'[Month No])))

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

5 REPLIES 5
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @shareezsaleem ,

 

I think MIN('Calendar'[Month Name]) should always return the oldest month.

Assuming the sorting of the column was set correctly.

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Not working.

If I clear the month name (Slicer) also, it should work- consider JAN month's no.

 

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @shareezsaleem ,

 

made a mistake in the behavior.

Maybe you can better use the month as a number to filter or determine the assignment as follows.

Oldest Month = MINX(FILTER(ALL('Calendar'[Month Name], 'Calendar'[Month No]), 'Calendar'[Month No] =  MIN('Calendar'[Month No])), 'Calendar'[Month Name])

 

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


I am not able to attach files in this thread.

Can you please explain me how to ammend this formula?

 

CALCULATE(DISTINCTCOUNT(Contracts_Details[Contract Ref.]),filter('Calendar','Calendar'[Month Name]="Jan"))

Here Jan should be replaced by the oldest month, if no month is selected it should consider 'Jan'.

If I select May, Feb, July- then it should consider Feb (Oldest month).

 

Keep in mind that I have 2 Slicers- One for year and another for Month Name.

mwegener
Most Valuable Professional
Most Valuable Professional

@shareezsaleem 

do you also have a numeric month column?

Then it would look like this.

CALCULATE(DISTINCTCOUNT(Contracts_Details[Contract Ref.]),filter('Calendar','Calendar'[Month No]=MIN('Calendar'[Month No])))

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.