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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Add table column that sum between dates using DATESBETWEEN - only returns value for current row

I've seen quite a lot of suggestions using the below approach on the internet, also on Microsoft's site - however, when I'm attempting to insert a custom column in a table to sum values across a period of time, it's only returning the value of the current row (can be seen in image further down). Here's the snippet used:

value sum = CALCULATE (
    SUM ('Table'[Value]); 
    DATESBETWEEN ('Table'[Date]; DATE (2019;1;1); DATE (2019;1;30))
    )

I have a table called "Table" (surprise) and inserted the above snippet. The result is as below: 

 

test.PNG

 

I've seen multiple sites stating taht this should SUM the values inbetween the dates, but for whatever reason I can't make it work? I've checked that there are no relations between the table in question and any others.

Am I missing something or 

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You dax is correct but it should be a measure. If you want use calculated column to show the sum, you can refer to the following dax:

Column =
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESBETWEEN ( 'Table'[Date], DATE ( 2019, 01, 01 ), DATE ( 2019, 01, 31 ) ),
    ALL ( 'Table' )
)

or

 

Column 2 =
SUMX (
    FILTER (
        'Table',
        'Table'[Date] >= DATE ( 2019, 01, 01 )
            && 'Table'[Date] <= DATE ( 2019, 01, 31 )
    ),
    'Table'[Value]
)

Here is the result.

2-1.PNG

The difference between measure and calculated column can be found in this link:

https://community.powerbi.com/t5/Desktop/column-vs-measure/td-p/13201

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

1 REPLY 1
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You dax is correct but it should be a measure. If you want use calculated column to show the sum, you can refer to the following dax:

Column =
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESBETWEEN ( 'Table'[Date], DATE ( 2019, 01, 01 ), DATE ( 2019, 01, 31 ) ),
    ALL ( 'Table' )
)

or

 

Column 2 =
SUMX (
    FILTER (
        'Table',
        'Table'[Date] >= DATE ( 2019, 01, 01 )
            && 'Table'[Date] <= DATE ( 2019, 01, 31 )
    ),
    'Table'[Value]
)

Here is the result.

2-1.PNG

The difference between measure and calculated column can be found in this link:

https://community.powerbi.com/t5/Desktop/column-vs-measure/td-p/13201

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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