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
Anonymous
Not applicable

Creating a quarter to date flag in a date table

Hi everyone,

 

I need to create a quarter to date flag, using DAX or M, in a date table where the fiscal year starts on 4/1. Below are the details around when there would need to be a "Y" within the Is_QTD flag column. Given it's currently June, the flag should show Y for Q1, or Apr - June.

Thanks in advance and kudos to anyone who can assist!

 

bchager6_0-1687269140838.png

 

 

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @Anonymous 

 

Give this a go

let
    CurrentDate = /* #date(2023, 7, 1) */ Date.From( DateTime.FixedLocalNow()),
    Source = Table.FromColumns(
        { List.Transform( {0..15}, each Date.AddMonths( #date(2023, 1, 1), _ )) },
        type table [ Date = date ]
    ),
    AddQTD = Table.AddColumn(Source, "IsQTD", each 
        [   y = if Date.Month(CurrentDate) >3 then 0 else 1, 
            r= ( [Date] >= Date.StartOfQuarter( #date( Date.Year( CurrentDate )-y, 4, 1))) and 
               ( [Date] < Date.EndOfQuarter(CurrentDate))
        ][r], type logical )
in
    AddQTD

 

with this result

m_dekorte_0-1687272996487.png

 

Ps If this helps to solve your query, please mark it as Solution, thanks!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thank you @slorin  and @m_dekorte . Do you know how I'd modfify the code to work with a date table that has a row for each day of every month? In other words; 4/1/23, 4/2/23 and so on.

slorin
Super User
Super User

Hi

let
Source = Table.FromColumns({List.Transform({0..11},each Date.AddMonths(#date(2023,4,1),_))}, type table [Month = date]),
Quarter = Table.AddColumn(Source, "Quarter", each Date.QuarterOfYear(Date.AddMonths([Month],-3)), Int64.Type),
#"Is QTD" = Table.AddColumn(Quarter, "Is QTD", each [Quarter]<=Date.QuarterOfYear(Date.AddMonths(Date.From(DateTime.LocalNow()),-3)))
in
#"Is QTD"

 

Stéphane 

m_dekorte
Super User
Super User

Hi @Anonymous 

 

Give this a go

let
    CurrentDate = /* #date(2023, 7, 1) */ Date.From( DateTime.FixedLocalNow()),
    Source = Table.FromColumns(
        { List.Transform( {0..15}, each Date.AddMonths( #date(2023, 1, 1), _ )) },
        type table [ Date = date ]
    ),
    AddQTD = Table.AddColumn(Source, "IsQTD", each 
        [   y = if Date.Month(CurrentDate) >3 then 0 else 1, 
            r= ( [Date] >= Date.StartOfQuarter( #date( Date.Year( CurrentDate )-y, 4, 1))) and 
               ( [Date] < Date.EndOfQuarter(CurrentDate))
        ][r], type logical )
in
    AddQTD

 

with this result

m_dekorte_0-1687272996487.png

 

Ps If this helps to solve your query, please mark it as Solution, thanks!

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.