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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
rjekrej
Frequent Visitor

Question regarding MAX DAX formula concerning date table and fact table

Hi everyone 

 

I have a star schema model where i have some dimension tables and a fact table. The dates in the dimension date table go to the end of the year 2025. The fact table date is always to days date.

 

I want to calculate visits year-to-date but the formula below (v.1) does not work but v.2 do. Can anyone explain why v.2 works and v.1 does not?

 

YTD (v.1) =
CALCULATE ( [Visits], DATESYTD ( Dim_dato[Date] ) )

 

YTD (v.2) =
CALCULATE (
    CALCULATE ( [Visits], DATESYTD ( Dim_dato[Date] ) ),
    Dim_dato[Date] <= MAX ( 'Fact_besøg'[Date] )
)

 

 

3 REPLIES 3
Anonymous
Not applicable

Hi @rjekrej ,

 

Normally, if your Dim_dato table has continuous single date and is connected to Fact_besøg table, DATESYTD() should work in this situation.

My Sample:

RicoZhou_0-1675758622892.png

Dim_dato = CALENDARAUTO() 

RicoZhou_1-1675758647045.png

Result is as below.

RicoZhou_2-1675758664077.png

You can check whether your data model is same as mine. Your issue should be caused by the calculation logic of [Visit] measure. In my sample, [Visit] measure is only a sum measure. You can check yours as well.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi 

 

Thank you very much for you help. It was great, it works. In my calender dim table i have a value for the date 1/1/1900 ( i cannot remove it) along with date values for the year 2022 and 2023. Do you know in DAX how exclude the 1/1/1900 and still make the formula work? 

amitchandak
Super User
Super User

@rjekrej , You can try measure like

 

YTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

or

 

YTD =
var _max = MAX( 'Date'[Date])
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors