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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
owlet0214
Helper I
Helper I

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.
 
diff1.PNG

 

 

1 ACCEPTED SOLUTION
az38
Community Champion
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])

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

3 REPLIES 3
az38
Community Champion
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])

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Finally it worked!

Thank you!

Thank you very much.

I have a meeting so I will try it later.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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