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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
vicky_
Super User
Super User

Calculating Cumulative Totals for a Measure DAX

Hello! 

I've run into a problem trying to make the following measure cumulative. The first screenshot shows my current output, and the part in the red box is what I want as an output. The week date range is a calculated column based on my Date Table. 
The user needs to be able to set the date range in the slicer. 

 

Weekly Spend Goal = 
var daysInPeriuod = CALCULATE(COUNT('Date'[Date]))
var allDays = COUNTX(ALLSELECTED('DateTable'[Date]), DateTable[Date])
var weeklyAmt = DIVIDE(1000, allDays) * daysInPeriuod
return weeklyAmt

 

vicky__2-1684383405617.png

Screenshot 1 showing my current output & desired output

 

vicky__1-1684383274487.png

Screenshot 2: the date table 

 

Thanks in advance for any help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Try this...

Spend Goal (Tier 1) = 
VAR LastDateInRange = MAXX(ALLSELECTED('Date'),'Date'[Date])
VAR FirstDateInRange = MINX(ALLSELECTED('Date'),'Date'[Date])
VAR AllDays = 
    COUNTROWS(
        FILTER(
            ALLSELECTED('Date'),
            'Date'[Date]>=FirstDateInRange && 
            'Date'[Date] <= LastDateInRange
            )
        )
VAR DIP = 
    COUNTROWS(
        FILTER(
            ALLSELECTED('Date'),
            'Date'[Date]>=FirstDateInRange && 
            'Date'[Date] <= MAXX('Date','Date'[Date])
            )
        )
RETURN DIVIDE(1000,AllDays)*DIP

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Try this...

Spend Goal (Tier 1) = 
VAR LastDateInRange = MAXX(ALLSELECTED('Date'),'Date'[Date])
VAR FirstDateInRange = MINX(ALLSELECTED('Date'),'Date'[Date])
VAR AllDays = 
    COUNTROWS(
        FILTER(
            ALLSELECTED('Date'),
            'Date'[Date]>=FirstDateInRange && 
            'Date'[Date] <= LastDateInRange
            )
        )
VAR DIP = 
    COUNTROWS(
        FILTER(
            ALLSELECTED('Date'),
            'Date'[Date]>=FirstDateInRange && 
            'Date'[Date] <= MAXX('Date','Date'[Date])
            )
        )
RETURN DIVIDE(1000,AllDays)*DIP

Hey thank you!

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.