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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bklyn3
Advocate II
Advocate II

Running Sum when using date hierarchy

Hello

I am trying to do something that should be very very simple :  A cummulative sum.

I have the following measure : 
 

RunningSum =

CALCULATE(
    SUM(BaselineTrackingVariableBase[Adj]),
    FILTER(
        ALL(BaselineTrackingVariableBase[Action Date],'BaselineTrackingVariableBase'[Type]),
        BaselineTrackingVariableBase[Action Date] <= MAX(BaselineTrackingVariableBase[Action Date])  &&  BaselineTrackingVariableBase[Type] = "Baseline"
    )
)

Now, if I use this measure on a bar graph with line and a date hierachy on the x axis , it seems that the cummulative sum reset at each new quarter or month or whatever my date level is.
How do I make sure it always takes all the data despite the date hierachy being displayed ? 

bklyn3_0-1672785822932.png



If I don't use the "Date hieachy" in the X axis but just the date, it does work but that is not what I want to do

 

bklyn3_1-1672785897125.png

 

Thank you 
 
 
1 ACCEPTED SOLUTION
ybacal
New Member

I just realize that when using Quick measures you can select the hierarchi level for which you want the running total to work, if you just add them all (select one on the user interface then add the rest on the formula bar), the graph should work.

RunningSum =

CALCULATE(

    SUM(BaselineTrackingVariableBase[Adj]),

    FILTER(

        CALCULATETABLE(

            SUMMARIZE(

                ' BaselineTrackingVariableBase',

                ' BaselineTrackingVariableBase' [Action Date].[MonthNo],

                ' BaselineTrackingVariableBase' [Action Date].[Year],
                '
BaselineTrackingVariableBase' [Action Date].[Quarter],                             

                ' BaselineTrackingVariableBase' [Action Date].[Month]

            ),

            ALLSELECTED(' BaselineTrackingVariableBase')

        ),

        ISONORAFTER(

            ' BaselineTrackingVariableBase' [Action Date].[MonthNo], MAX(' BaselineTrackingVariableBase' [Action Date].[MonthNo]),DESC,

            ' BaselineTrackingVariableBase' [Action Date].[Year], MAX(' BaselineTrackingVariableBase' [Action Date].[Year]),DESC,

            ' BaselineTrackingVariableBase' [Action Date].[Quarter], MAX(' BaselineTrackingVariableBase' [Action Date].[Quarter]),DESC,

            ' BaselineTrackingVariableBase' [Action Date].[Month], MAX(' BaselineTrackingVariableBase' [Action Date].[Month]),DESC

        )  &&  BaselineTrackingVariableBase[Type] = "Baseline"

    )

)

 



View solution in original post

2 REPLIES 2
ybacal
New Member

I just realize that when using Quick measures you can select the hierarchi level for which you want the running total to work, if you just add them all (select one on the user interface then add the rest on the formula bar), the graph should work.

RunningSum =

CALCULATE(

    SUM(BaselineTrackingVariableBase[Adj]),

    FILTER(

        CALCULATETABLE(

            SUMMARIZE(

                ' BaselineTrackingVariableBase',

                ' BaselineTrackingVariableBase' [Action Date].[MonthNo],

                ' BaselineTrackingVariableBase' [Action Date].[Year],
                '
BaselineTrackingVariableBase' [Action Date].[Quarter],                             

                ' BaselineTrackingVariableBase' [Action Date].[Month]

            ),

            ALLSELECTED(' BaselineTrackingVariableBase')

        ),

        ISONORAFTER(

            ' BaselineTrackingVariableBase' [Action Date].[MonthNo], MAX(' BaselineTrackingVariableBase' [Action Date].[MonthNo]),DESC,

            ' BaselineTrackingVariableBase' [Action Date].[Year], MAX(' BaselineTrackingVariableBase' [Action Date].[Year]),DESC,

            ' BaselineTrackingVariableBase' [Action Date].[Quarter], MAX(' BaselineTrackingVariableBase' [Action Date].[Quarter]),DESC,

            ' BaselineTrackingVariableBase' [Action Date].[Month], MAX(' BaselineTrackingVariableBase' [Action Date].[Month]),DESC

        )  &&  BaselineTrackingVariableBase[Type] = "Baseline"

    )

)

 



FreemanZ
Super User
Super User

hi @bklyn3 

in cases like this, i would

1) create needed month, quarter columns in the Date Table. 

2) write different measures for running total over different levels. e.g. if  running over quarter,  we put quarter inside MAX. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.