Forum Discussion
Anonymous
3 years agoNot applicable
DAX - Count Days Between two date fields on a Date Axis
Hello, I'm trying to use DAX to count every day between two date fields for a large dataset and create a stacked column chart broken out by Program. You can do this in excel by means of the COUN...
- 3 years ago
Hi,
hope this will help you. Dynamic measure based on your calendar.
Count Correct Rows =var date_ref = SELECTEDVALUE(dim_calendar[Date])returnCOUNTX(FILTER('Sample';AND('Sample'[Status Start Date] <= date_ref;'Sample'[Status End Date]>=date_ref));COUNTROWS('Sample'))You can use Program column as you want. No relationship needed.
bolfri
Solution Sage
3 years agoHi,
hope this will help you. Dynamic measure based on your calendar.
Count Correct Rows =
var date_ref = SELECTEDVALUE(dim_calendar[Date])
return
COUNTX(
FILTER('Sample';AND('Sample'[Status Start Date] <= date_ref;'Sample'[Status End Date]>=date_ref));
COUNTROWS('Sample')
)
You can use Program column as you want. No relationship needed.
Anonymous
3 years agoNot applicable
Hi bolfri ,
This Solution does exactly as expected. Thank you!
One follow-up question. I'd like to show date hierarchy on my axis, with date rolling up to Month & Quarter. PBI will not accept the Month or Quarter axis - visual shows blank when I try that. Is there a way to rewrite this to account for those? Can they be included as variables?
Thanks again!