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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Ryks
Frequent Visitor

Dax - Filter by 2 date columns - Metric

Hi

 

I hope somebody can help me.

Question:

How many order were open per month.

I have a date table - Calendar(Date) that has an active relationship with Open.  

 

Data set

IDOpenClose
115-Jan-21 
220-Feb-2120-Mar-21
301-Jan-2120-Mar-21
410-Jan-2128-Apr-21

 

Answer should be:

Feb-214
Mar-212
Apr-211

 

I tried countrows and filter, but cannot get it to work.

 

This does not work:

Open = Calculate(CountA('Position Open'[ID]),Filter('Position Open',(Month(‘Position Open’[Open])<=Calendar(Month) && Year(Position Open’[Open])<=Calendar(Year) && isempty('Position Open'[Close]) ||  Month('Position Open'[Close]) > Calendar(Month) && Year(Position Open’[Position Open Date])>Calendar(Year))

 

Thanks for any suggestions.

2 ACCEPTED SOLUTIONS

@Ryks 

you can modify the measure by adding ALL function

Measure = 
CALCULATE(COUNTROWS('Table'),FILTER(all('Table'),('Table'[Close]>max('Date'[Date])||ISBLANK('Table'[Close]))&&'Table'[Open]<max('Date'[Date])))

pls see the attachment below

 





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

Proud to be a Super User!




View solution in original post

9 REPLIES 9
Greg_Deckler
Community Champion
Community Champion

@Ryks 
Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

Great solution. 

I however, have relationships on my table.

Active - Open to Calendar Date and inactive with Close.

 

 

ryan_mayu
Super User
Super User

@Ryks 

you can try this

Measure = 
CALCULATE(COUNTROWS('Table'),FILTER('Table',('Table'[Close]>max('Date'[Date])||ISBLANK('Table'[Close]))&&'Table'[Open]<max('Date'[Date])))

pls see the attachment below





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

Proud to be a Super User!




Wow, @ryan.  Amazying!  

Just checking my data set, will get back to you.

Many Thanks

 

you are welcome





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

Proud to be a Super User!




Hi @ryan_mayu 

The reason why my data does not work, is that I have a active relationship between calander date and inactive relationship between calander date and close.  I am playing around with

USERELATIONSHIP but have not landed on anything. 

@Ryks 

you can modify the measure by adding ALL function

Measure = 
CALCULATE(COUNTROWS('Table'),FILTER(all('Table'),('Table'[Close]>max('Date'[Date])||ISBLANK('Table'[Close]))&&'Table'[Open]<max('Date'[Date])))

pls see the attachment below

 





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

Proud to be a Super User!




Excellent.

Thank you @ryan_mayu 

you are welcome





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

Proud to be a Super User!




Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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