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
Nakul93
Regular Visitor

how to calculate difference between max of daily dates?

I have a table where the data keeps on incrementing continously, I am able to get max of each day. But what I want to achieve here is total of each day i.e difference of max values between each days. Here is a sample of both raw data and max of cycles per day, please help

Capture.PNG

 

Capture1.PNG

1 ACCEPTED SOLUTION

Try this formula instead:

 

DateMaxDiff =
VAR __PREV_DAY =
    CALCULATE ( [DateMaxValue_], DATEADD ( 'Table'[Date], -1, DAY ) )
RETURN
    IF ( NOT ( ISBLANK ( [DateMaxValue_] ) ), [DateMaxValue_] - __PREV_DAY )









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @Nakul93,

 

Try this:

 

Extract the date part of tts column by creating a calculate column

Date =
INT ( 'Table'[tts] )

Note: This column will be formatted as decimal by default. Change the format to date.

 

Create a new measure to get the max value per date.

DateMaxValue = 
CALCULATE ( MAX ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Date] ) )

Create another measure to get the difference between two dates

DateMaxDiff = 
VAR __PREV_DAY =
    CALCULATE ( [DateMaxValue_], DATEADD ( 'Table'[Date], -1, DAY ) )
RETURN
    [DateMaxValue_] - __PREV_DAY









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian,

Your solution worked somewhat but it is now showing data for the future date as well. Just look at the report attachedCapture.PNG

 

The data is from 24th june to 2nd july...but it is showing data of july 3rd as well and the value 11169 is the total sumThe data is from 24th june to 2nd july...but it is showing data of july 3rd as well and the value 11169 is the total sum

 

Try this formula instead:

 

DateMaxDiff =
VAR __PREV_DAY =
    CALCULATE ( [DateMaxValue_], DATEADD ( 'Table'[Date], -1, DAY ) )
RETURN
    IF ( NOT ( ISBLANK ( [DateMaxValue_] ) ), [DateMaxValue_] - __PREV_DAY )









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.