cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Narender Member
Member

Add Quarter in Calender

Hi All,

I need a quarter in my Report . 

I have already a calender which I created via script as shown below.

 

 

Dates =
GENERATE (
CALENDAR( DATE( YEAR( TODAY() ) - 4, MONTH( TODAY() ), DAY( TODAY()) ), TODAY()),
VAR startOfWeek = 1 // Where 1 is Sunday and 7 is Saturday, thus a 3 would be Tuesday
VAR currentDay = [Date]
VAR days = DAY( currentDay )
VAR months = MONTH ( currentDay )
VAR years = YEAR ( currentDay )
VAR nowYear = YEAR( TODAY() )
VAR nowMonth = MONTH( TODAY() )
VAR MonthName = FORMAT(DATE(2016,MONTH(currentDay),1),"MMMM")
VAR dayIndex = DATEDIFF( currentDay, TODAY(), DAY) * -1
VAR todayNum = WEEKDAY( TODAY() )
VAR weekIndex = INT( ROUNDDOWN( ( dayIndex + -1 * IF( todayNum + startOfWeek <= 6, todayNum + startOfWeek, todayNum + startOfWeek - 7 )) / 7, 0 ) )
RETURN ROW (
"Day", days,
"Month", months,
"Month Name",MonthName,
"Year", years,
"Day Index", dayIndex,
"Week Index", weekIndex,
"Month Index", INT( (years - nowYear ) * 12 + months - nowMonth ),
"Year Index", INT( years - nowYear )
)
)

 

Please tell me , how can I add Querter in script.

 

Thanks,

 

Narender

2 ACCEPTED SOLUTIONS

Accepted Solutions
Microsoft Phil_Seamark
Microsoft

Re: Add Quarter in Calender

    "Quarter" , "Q" & INT((MONTH(currentDay)/4)) + 1)

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

Proud to be a Datanaut!

View solution in original post

Narender Member
Member

Re: Add Quarter in Calender

Hi Phil,

 

I did this, Which is working fine.

 

  VAR quarter  = CONCATENATE("Q",ROUNDUP(MONTH(currentDay)/3,0))

 

 

Is it ok?

 

 

Thanks,

 

Narender

 

View solution in original post

3 REPLIES 3
Microsoft Phil_Seamark
Microsoft

Re: Add Quarter in Calender

    "Quarter" , "Q" & INT((MONTH(currentDay)/4)) + 1)

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

Proud to be a Datanaut!

View solution in original post

Narender Member
Member

Re: Add Quarter in Calender

Hi Phil,

 

I did this, Which is working fine.

 

  VAR quarter  = CONCATENATE("Q",ROUNDUP(MONTH(currentDay)/3,0))

 

 

Is it ok?

 

 

Thanks,

 

Narender

 

View solution in original post

Microsoft Phil_Seamark
Microsoft

Re: Add Quarter in Calender

Nice, looks good.  Might pay to have a DateTime version of the column too so you get the full benefit on some visuals.

 

Something like 

 

Start of Quarter = 
    DATE
    (
    YEAR(currentDay) , 
    CONCATENATE("Q",ROUNDUP(MONTH(currentDay)/3,0)) ,
    1)

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

Proud to be a Datanaut!

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors