Forum Discussion

monojchakrab's avatar
monojchakrab
Icon for Resolver III rankResolver III
4 years ago
Solved

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 returnin...
  • amirabedhiafi's avatar
    4 years ago

    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.

  • SpartaBI's avatar
    4 years ago

    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)

  • amirabedhiafi's avatar
    amirabedhiafi
    4 years ago

    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.