Parham.Trader
Parham.Trader

Reputation: 47

Running MAX of values in another column in DAX

I'm working on having a column whose values are the running MAX of another column.

My main table has three columns and I use the summarize function to virtually add another column named as SUM OF EACH DATETIME to the summarized table. Now I want to have the running MAX of the SUM OF EACH DATETIME column in the summarized table in another new column as MAX of Sum column. My table and its preferred columns are shown below:

enter image description here

I'd appreciate it if you kindly guide me how can I have the MAX of Sum column in my summarized table. I should note that the formula to calculate the SUM OF EACH DATETIME column is:

SUMMARIZE(TABLE, TABLE[DateTimeStamp],
 "SUM OF EACH DATETIME", IF(COUNTROWS(TABLE)=calculate(DISTINCTCOUNT(TABLE[Name]), ALLSELECTED()),SUM(TABLE[Value]),BLANK())) 

Upvotes: 1

Views: 1314

Answers (1)

mkRabbani
mkRabbani

Reputation: 16918

You can create one measure and one column as given below.

Column:

date_sum_column = 

var current_row_date_time = ('your_table_name'[DateTimeStamp])

return
CALCULATE(
    SUM('your_table_name'[Value]),
    FILTER(
        ALL('your_table_name'),
        'your_table_name'[DateTimeStamp] = current_row_date_time
    )
)

Measure:

running_max_sum = 
CALCULATE(
    MAX(your_table_name[date_sum_column]),
    FILTER(
        ALL(your_table_name),
        your_table_name[DateTimeStamp] <= MIN(your_table_name[DateTimeStamp])
    )
)

Here is the output:

enter image description here

Upvotes: 1

Related Questions