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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
daltonrotork
Frequent Visitor

calculate the change from latest date from earliest date from a table

Hi - I have a table in Power BI like so

CompanyValueMonth-Year
Head office42Jan 23
Head office53Jun 23
Head office63Dec 23
Factory56Jan 23
Factory65Jun 23
Factory67Dec 23

Etc

And I'm looking for DAX that would show the difference from the latest date in the table to the earliest date; so Dec 23 value - Jan 23 value, as a number and a percentage for each company - can anyone help me out with that?

Thanks!

2 REPLIES 2
johnt75
Super User
Super User

I think you could create a measure like

% diff =
VAR FirstValue =
    SELECTCOLUMNS (
        INDEX (
            1,
            'Table',
            ORDERBY ( 'Table'[Month-Year], ASC ),
            PARTITIONBY ( 'Table'[Company] ),
            MATCHBY ( 'Table'[Month-Year], 'Table'[Company] )
        ),
        "@value", 'Table'[Value]
    )
VAR LastValue =
    SELECTCOLUMNS (
        INDEX (
            1,
            'Table',
            ORDERBY ( 'Table'[Month-Year], DESC ),
            PARTITIONBY ( 'Table'[Company] ),
            MATCHBY ( 'Table'[Month-Year], 'Table'[Company] )
        ),
        "@value", 'Table'[Value]
    )
VAR Result =
    DIVIDE ( LastValue - FirstValue, FirstValue )
RETURN
    Result
some_bih
Super User
Super User

Hi @daltonrotork  measure could be:

Range as measure:
VAR _max_date=MAX(<Your table>[Month-Year])

VAR _min_date=MIN(<Your table>[Month-Year])
RETURN 
CALCULATE( SUM( <Your table>[Value]),

_max_date-  _min_date)

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

 

 

 





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

Proud to be a Super User!






Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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