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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
CK-NL
Regular Visitor

How to calculate timeslots column in DAX?

Hello all,

 

I have a table as follows, spanning several years (this is an exerpt):

DateYearQuarterMonthnumberTimeslot
1-7-20222022Q37 
2-7-20222022Q37 
3-7-20222022Q37 
4-7-20222022Q37 
5-7-20222022Q37 
6-7-20222022Q37 

 

It is used in a dashboard that shows the results of a questionnaire that is filled in periodically by people all over the organisation. This data is aggregated into scores and I want to show trends. For visualisation purposes I want to cluster responses over a specific period into one 'timeslot', one point at which the organisation is measured. So I can compare it to other 'timeslots'. 

 

The questionnaire is roughly run from September until March so I want to make a cutoff in June and put everything between July and June in a timeslot 1, the space in between the next July and June in timeslot 2, and so forth.

 

The date table is a calculated table that is attuned to the minimal and maximal date in the dataset.

 

What is the best way to create this timeslot column in DAX? 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

The best way is to NOT do this in DAX.  Use an external calendar table, add the column there, and then consume that table as part of your dataset.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with a calculated column to extract the Month number.  In another calculated column, write this formula

Year slot = if(calendar[month number]>=8,year(calendar[Date])&"-"&year(calendar[Date])+1,year(calendar[Date])-1&"-"&year(calendar[Date]))

Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of your Calendar Table.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
CK-NL
Regular Visitor

To keep my data lean and mean I have a calculated date table (DAX-generated). I need to do it in DAX because it needs to be dynamic to remain in sync with the dates in the table.

You're saying to drop the calculated table and add a static calendar table where this column is a part of?

I need to do it in DAX because it needs to be dynamic to remain in sync with the dates in the table.

not buying this argument.  Dates tables tend to be small, a couple thousand rows max. It is very unlikely that they will create something like a Feb 30th any time soon. 

 

From my experience (and YMMV of course) implementing calendar tables in DAX or Power Query is a waste of time (pun not intended).

@lbendlin I am very much inclined to lean your way because I agree with you that a calender table can never be that large. And I am very sure my mileage is dwarfed by yours.

 

However, why is this dynamic table concept taught in every Power BI course? As to avoid as much data redundancy as possible.

I guess it's a nice finger exercise, and ADDCOLUMNS and FORMAT will come in handy in other situations. Tool knowledge is important for sure, but it is also important to know when not to use a particular tool.

lbendlin
Super User
Super User

The best way is to NOT do this in DAX.  Use an external calendar table, add the column there, and then consume that table as part of your dataset.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors