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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register 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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.