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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Help with DAX formula in a created table to do MTD/QTD/YTD filter

I have used this table in several projects and haven't had any troubles before. But i tried to use it today and it doesn't work anymore. 

 

MTD/QTD/YTD =
VAR TodayDate = TODAY()
VAR YearStart = CALCULATE(STARTOFYEAR(Query1[Fecha]), YEAR(Query1[Fecha]) = YEAR(TodayDate))
VAR QuarterStart = CALCULATE(STARTOFQUARTER(Query1[Fecha]), YEAR(Query1[Fecha]) = YEAR(TodayDate), QUARTER(Query1[Fecha]) = QUARTER(TodayDate))
VAR MonthStart = CALCULATE(STARTOFMONTH(Query1[Fecha]), YEAR(Query1[Fecha]) = YEAR(TodayDate), MONTH(TodayDate) = MONTH(TodayDate))
VAR Result =
UNION(
ADDCOLUMNS(
CALENDAR(YearStart, TodayDate),
"Selection", "YTD"
),
ADDCOLUMNS(
CALENDAR(QuarterStart, TodayDate),
"Selection", "QTD"
),
ADDCOLUMNS(
CALENDAR(MonthStart, TodayDate),
"Selection", "MTD"
)
)
RETURN
ResultCaptura de pantalla (56).png
2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous,

Did PaulDBrown 's suggestions help with your scenario? if that is the case, you can consider Kudo or accept his suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

PaulDBrown
Community Champion
Community Champion

Try using FILTER and the && in the VAR expressions. For example

VAR QuarterStart = CALCULATE(STARTOFQUARTER(Query1[Fecha]), FILTER(Query1, YEAR(Query1[Fecha]) = YEAR(TodayDate) && QUARTER(Query1[Fecha]) = QUARTER(TodayDate)))





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.