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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Kevboy_telford
Frequent Visitor

Show min date data

I want a user to be able to select a date range and Power BI to show the data for the first date and last date only  

I would try using summarize but I need to be able to calculate on the fly....

 

I have the following measures

 

earliestdate = min('Calendar'[Date])

latestdate = max('Calendar'[Date])

 

FirstDateCount = CALCULATE(DISTINCTCOUNT('Customer_Journey'[customerid]),FILTER('JM_Insight Calendar','JM_Insight Calendar'[Date]<=[earliestdate]))

LastDateCount = CALCULATE(DISTINCTCOUNT('Customer_Journey'[customerid]),FILTER('JM_Insight Calendar','JM_Insight Calendar'[Date]>=[latestdate]))

 

however both FirstDateCount and LastDateCount are giving me the same answer...

 

equivalent in SQL that I am trying to do is:

 

DECLARE @customerselectedDate_first DATE = '20180101' 
DECLARE @customerselectedDate_last  DATE = '20180430' 

SELECT current_status, 
       Count(DISTINCT customerid) AS customers 
FROM   customer_journey 
WHERE  dates = @customerselectedDate_first 
GROUP  BY current_status 

SELECT current_status, 
       Count(DISTINCT customerid) AS customers 
FROM   customer_journey 
WHERE  dates = @customerselectedDate_last 
GROUP  BY current_status 

 

1 ACCEPTED SOLUTION
Floriankx
Solution Sage
Solution Sage

Hello you can dim your variable in the formula:

 

FirstDateCount = 
VAR EarlieastDate = MIN('Calendar'[Date])
RETURN
CALCULATE(DISTINCTCOUNT('Customer_Journey'[customerid]),
FILTER('JM_Insight Calendar','JM_Insight Calendar'[Date]=[EarliestDate]))

Are Customer_Journey and JM_Insight Caledar related?

View solution in original post

2 REPLIES 2
Floriankx
Solution Sage
Solution Sage

Hello you can dim your variable in the formula:

 

FirstDateCount = 
VAR EarlieastDate = MIN('Calendar'[Date])
RETURN
CALCULATE(DISTINCTCOUNT('Customer_Journey'[customerid]),
FILTER('JM_Insight Calendar','JM_Insight Calendar'[Date]=[EarliestDate]))

Are Customer_Journey and JM_Insight Caledar related?

That is weird - it works when I have it as a VAR within the measure but not when its separate

 

Thanks for your help!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.