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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
kyleldi
Frequent Visitor

Counting data between two date ranges

I have a delivery table that contains a date column and a status column.  I'm looking to graph that data by status by month and rolling week.  The data appears correctly on the Data Detail table I made (pictured), but will not graph accordingly.  I've created a table (OTD) that bins the data by month, but does not sum the status correctly by month as it should.  Being new to DAX, I'm not sure how to capture both the date range and the status in my column.  Any help would be gratefully appreciated.OTD Power BI TableOTD Power BI Table

 

 

GraphsGraphs

 

 

vw_PBI-OnTimeDelivery SQL Viewvw_PBI-OnTimeDelivery SQL View

 

 

 

 

3 REPLIES 3
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @kyleldi

 

What is the code you have used to create your OTD table?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

@Phil_Seamark Here's my code for the OTD table.

 

OTD = DISTINCT('vw_PBI-OnTimeDelivery'[Shipped_Date (bins)])
Anonymous
Not applicable

Hi @kyleldi,

 

If you want to get the distinct count of selected date range, you can try to use below formula:

Count of Selected DateRange= 
var selectedMin=FIRSTDATE(ALLSELECTED('Table'[Date]))
var selectedMax=LASTDATE(ALLSELECTED('Table'[Date]))
return
CALCULATE(DISTINCTCOUNT('vw_PBI-OnTimeDelivery'[Shipped_Date (bins)]),FILTER(ALL('Table'),[Date]>=selectedMin&&[Date]<=selectedMax))

 

Notice: table is the source table of the date slicer.

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors