Forum Discussion

owlet0214's avatar
owlet0214
Helper I
6 years ago
Solved

Difference from previous cel (Additional consultation)

Hello,

It is related to a question I previously asked.

 

https://community.powerbi.com/t5/Desktop/Difference-from-previous-cell/m-p/1091974

 

I am unable to solve the following problems.

I am counting the difference of the counts the day before (DAX_diff2).

However, the number of counts is sometimes revised and may be negative compared to the previous day.

 

Then I can't calculate well.

In the example below, the calculation is not "difference between a certain day and the day before that day" but "difference between a certain day and the maximum value up to the previous day".

 

I want to set the value of "max_test1" to "249,619" when the value of "Dax_Last_date" is 5/20.

The formula I'm using is:

 

DAX_Last date = maxx(filter('Table',[Country/Region]=earlier([Country/Region]) && [YYYYMMDD] <earlier([YYYYMMDD])),[YYYYMMDD])

 

DAX_diff2(case_a_day) = [count_cum] - maxx(filter('Table',[Country/Region]=earlier([Country/Region]) && [DAX_Last date] <earlier([DAX_Last date])),[count_cum])

 

maxx_test1 = maxx(filter('Table',[Country/Region]=earlier([Country/Region]) && [DAX_Last date] <earlier([DAX_Last date])),[count_cum])

 
Please help.
 

 

 

  • Hi owlet0214 

    your max_test returns the MAX value for all previous period.

    you need smth like

    maxx_test1 = 
    var _maxDate = maxx(filter('Table',[Country/Region]=earlier([Country/Region]) && [DAX_Last date] <earlier([DAX_Last date])),[DAX_Last date])
    
    RETURN
    
    maxx(filter('Table',[Country/Region]=earlier([Country/Region]) && [DAX_Last date] = _maxDate),[count_cum])

3 Replies

  • az38's avatar
    az38
    Community Champion

    Hi owlet0214 

    your max_test returns the MAX value for all previous period.

    you need smth like

    maxx_test1 = 
    var _maxDate = maxx(filter('Table',[Country/Region]=earlier([Country/Region]) && [DAX_Last date] <earlier([DAX_Last date])),[DAX_Last date])
    
    RETURN
    
    maxx(filter('Table',[Country/Region]=earlier([Country/Region]) && [DAX_Last date] = _maxDate),[count_cum])