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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

@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


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors