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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
monojchakrab
Resolver III
Resolver III

summing a column value between two specific dates

I am trying to sum a sales column between two dates as follows :

Measure = CALCULATE(Sum'table name'[col. name], DATESBETWEEN('date table'[date], DATE(2022,03,01),DATE(2022,03,15))

It is returning nothing.

The date table is generated thru' Calendarauto() function and is related to the main table date column called "purchase date". The main column has other date columns  though.

I have also tried writing the measure with the date column within the main table - it still does not work.

Am I missing something or the relationship between the date table and the query table is not set up right?

Any help appreciated.

Thanks

3 ACCEPTED SOLUTIONS
amirabedhiafi
Impactful Individual
Impactful Individual

@monojchakrab  if you need the timestamp in your analysis, you can simply duplicate the timestamp column and then change the column data type to Date and use it when you need only date.

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini

View solution in original post

SpartaBI
Community Champion
Community Champion

@monojchakrab , your measure was correct.
The reason it diden't work is becasue the relationship between the auto date table (or any standatd date table you would have made) is based on the date column. This is not a group by relationship -> 01/01/2022 in the date table <> 01/01/2022 00:01 in the main table, so nothing was picked up in the relationship. If you want to use time intelligence calculations -> you need a date table -> you need a date column in the related table (main/fact). If you need to also do calulcaitons based on time, the best practice is to split the original column into date column and time column (by they way both of them are date/time columns in the tabular model but the date column corresponds to dates with no value in the time and the time column corresponds to to deifferent times in 30/12/1899).  Than you can make a dimenstion table for the time colunm - alltough not necessary if you only have 1 fact table, but allways a good idea if you are going to use this column in filters (due to the auto exist behaviour in summarizecloumns function which is used pretty much for every pivotal visual in Power BI)

View solution in original post

@SpartaBI  I totally agree. @monojchakrab The date tables are important in Power BI because you'll need them to reference dates inside your model. On top of that, building a date table can help if you need specific date information for your reports. It's important to get your date tables right if you plan on using them for time intelligence calculations.

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini

View solution in original post

9 REPLIES 9
SpartaBI
Community Champion
Community Champion

@monojchakrab , your measure was correct.
The reason it diden't work is becasue the relationship between the auto date table (or any standatd date table you would have made) is based on the date column. This is not a group by relationship -> 01/01/2022 in the date table <> 01/01/2022 00:01 in the main table, so nothing was picked up in the relationship. If you want to use time intelligence calculations -> you need a date table -> you need a date column in the related table (main/fact). If you need to also do calulcaitons based on time, the best practice is to split the original column into date column and time column (by they way both of them are date/time columns in the tabular model but the date column corresponds to dates with no value in the time and the time column corresponds to to deifferent times in 30/12/1899).  Than you can make a dimenstion table for the time colunm - alltough not necessary if you only have 1 fact table, but allways a good idea if you are going to use this column in filters (due to the auto exist behaviour in summarizecloumns function which is used pretty much for every pivotal visual in Power BI)

@SpartaBI  I totally agree. @monojchakrab The date tables are important in Power BI because you'll need them to reference dates inside your model. On top of that, building a date table can help if you need specific date information for your reports. It's important to get your date tables right if you plan on using them for time intelligence calculations.

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini
amirabedhiafi
Impactful Individual
Impactful Individual

@monojchakrab  if you need the timestamp in your analysis, you can simply duplicate the timestamp column and then change the column data type to Date and use it when you need only date.

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini
monojchakrab
Resolver III
Resolver III

I removed the time stamp from the [purchase date] column in the main query table and now somehow it seems to work.

But not sure that's the right approach as I am losing the time stamp on the sales which I must have for other analysisseems to workseems to worktime stamp removedtime stamp removed

monojchakrab
Resolver III
Resolver III

Is it possible that the time stamp on the [purchase date] column in the query table is different from those on the [date] field in the date table?

Is it possible to keep the time stamps as those are important information

monojchakrab
Resolver III
Resolver III

The screen shots with the measure will also show that the dates chosen do have data in the query table - so the date column from the Date table should be able to query the same dates from the table and sum the column for sales which in this case is named as "item price"

amirabedhiafi
Impactful Individual
Impactful Individual

Can you please share your model ?

Also are you sure that you have data for the range date that you provided ?

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini

Dax model queryDax model queryDate tableDate tableRelationshipRelationshipMeasure with dates from date tableMeasure with dates from date tableMeasure with date from query tableMeasure with date from query table

What is the format for :

-Date in Date Table

-PurchaseDate in the Amazon YTD Apr22

 

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.