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
Mat87
Frequent Visitor

Get the most recent value as it is

So I have a table like that looks like this:

 

aa2.png

 

What I want is to create a measure that get me the most recent value for each ID. So when I view the data in a pivottable it give me:

 

AA 12

BB 20

CC 15

DD 22

 

Any idea how I can get this done in DAX/powerpivot? 

3 REPLIES 3
v-jiascu-msft
Employee
Employee

@Mat87

 

Hi,

 

Could you tell me please if your problem is solved? You can mark the right answer to help others if it's convenient for you.

 

Best Regards!
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Employee
Employee

@Mat87

 

Hi,

 

Following @Greg_Deckler's idea, you need to do these steps.

  1. Choose columns 2007, 2008, 2009, 2010 with “Ctrl” pressed in Query Editor.
  2. Click “Unpivot Columns”.
  3. Change names “Attribute” to “Year”,.
  4. Create a measure:

Measure =

CALCULATE (

    MIN ( Table1[Value] ),

    FILTER ( Table1, Table1[Attribute] = MAX ( Table1[Attribute] ) )

)

 

If you only have columns 2007, 2008, 2009, 2010, you still can try a calculated column.

LatestValue =

IF (

    ISBLANK ( [2010] ),

    IF (

        ISBLANK ( [2009] ),

        IF ( ISBLANK ( [2008] ), IF ( ISBLANK ( [2007] ), BLANK (), [2007] ), [2008] ),

        [2009]

    ),

    [2010]

)

 

Get the most recent value as it is .jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

You are going to want to unpivot your data on import so that you get your table in a format like:

 

ID, Year, Value

 

You'll do this in the Query Editor. At that point, your problem is fairly trivial.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.