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
julienvdc
Helper III
Helper III

Dax measure calculating the evolution on the last 2 submissions/dates

Hey,

 

I have this table that lists percentages (value) for a bunch of recurring fields (field_id). I would like to build a mesaure that evaluated how those fields are evolving but only on the last 2 submissions/import. You can see we have information on the import date/time and each import has a dedicated file_id. So i think there is something to be done on either of these columns but I am not sure how to approach this.

 

I can easily find out the evolution across all imports, but the last 2 ... I am not sure... Any thoughts?

 

julienvdc_0-1708595026148.png

 

1 REPLY 1
v-jiewu-msft
Community Support
Community Support

Hi @julienvdc ,

Please try the following methods and check if they can solve your problem:

1.Create the new measure to identify the last two.

Last Two Imports = 
RANKX(
    ALL('Table'[imported_on]), 
    CALCULATE(MAX('Table'[imported_on])), 
    ,
    DESC, 
    Dense
)

2.Create the new measure to calculate the value for each field_id. Enter the following DAX formula.

ValueLastImports = 
VAR LastImportValue = CALCULATE(
    SUM('Table'[value]), 
    FILTER(
        'Table', 
        [Last Two Imports Rank] = 1
    )
)
VAR SecondLastImportValue = CALCULATE(
    SUM('Table'[value]), 
    FILTER(
        'Table', 
        [Last Two Imports Rank] = 2
    )
)
RETURN
IF(
    NOT(ISBLANK(SecondLastImportValue)),
    (LastImportValue - SecondLastImportValue) / SecondLastImportValue,
    BLANK()
)

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

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.