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
Anonymous
Not applicable

Dax get the value of the oldest row of a group

Hi everyone.

 

I have a table with debits, credits and other columns... some of those are the column with accounting accounts, initial balance and date of the initial balance.

 

The accounting accounts repeat in several raws, repeating the initial balance, so I need a measure which give me the first initial balance (ordered by the date of initial balance) of each accounting account.

 

For example:

Account   date                 initial balance

2               21/01/2020     $2

2                22/01/2020     $20

3               01/01/2019      $0

3                02/01/2019    $10

 

Result:

Account   date                 initial balance

 

2               21/01/2020     $2

 

3               01/01/2019      $0

 

Please if someone have an idea, I'll be so grateful.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@eduardosilvin - This looks like Lookup Min/Max - https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

If applicable, you can use MIN or "first" to get your Date in your visualization. For the initial balance:

Initial Balance Measure = 
  VAR __Account = MAX([Account])
  VAR __MinDate = MINX(FILTER('Table',[Account] = __Account),[date])
RETURN
  MINX(FILTER('Table',[Account] = __Account && [date] = __date),[initial balance])


@ 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...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

@eduardosilvin - This looks like Lookup Min/Max - https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

If applicable, you can use MIN or "first" to get your Date in your visualization. For the initial balance:

Initial Balance Measure = 
  VAR __Account = MAX([Account])
  VAR __MinDate = MINX(FILTER('Table',[Account] = __Account),[date])
RETURN
  MINX(FILTER('Table',[Account] = __Account && [date] = __date),[initial balance])


@ 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...
Anonymous
Not applicable

@Greg_Deckler works perfectly, thank you sooooo much!!!!

@Anonymous - Sorry that was supposed to be:

Initial Balance Measure = 
  VAR __Account = MAX([Account])
  VAR __MinDate = MINX(FILTER('Table',[Account] = __Account),[date])
RETURN
  MINX(FILTER('Table',[Account] = __Account && [date] = __MinDate),[initial balance])

 


@ 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...
Anonymous
Not applicable

@Greg_Deckler thank you, I have one question, at the end you wrote "_date", but im not sure what date should be there

amitchandak
Super User
Super User

@Anonymous ,

Create a measure like this

firstnonblankvalue(Table[date],sum(Table[initial balance]))

 

And use with Account and min(Table[date]) or First Table[date] in a visual

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.