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

Last Column Value

Dears,

 

Have a good day.

 

I need to get the last value of a column, just read it without calculation as the value is a cumulative value.

LastValue.JPG

 

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi aserag,

 

In your scenario, you want to achieve the value in the last row, right? For example, 54545 is what you want in column [Planned value] below.

3.PNG

The first solution is that you can create an index and use the max index to find the value, click Query Editor->Add Column->Index Column.

4.PNG

After applied, you can create a measure using DAX formula:

last value = CALCULATE(MAX(Table1[Planned Value]), FILTER(Table1, Table1[Index] = MAX(Table1[Index])))

5.PNG

 

The second solution is that you can simply use “Keep Bottom Rows” to achieve last value.

 

6.PNG7.PNG8.PNG

 

Regards,

Jimmy Tao

View solution in original post

8 REPLIES 8
samueltphilip
New Member

What if I want to take the last 5 elements insted of just one?

v-yuta-msft
Community Support
Community Support

Hi aserag,

 

In your scenario, you want to achieve the value in the last row, right? For example, 54545 is what you want in column [Planned value] below.

3.PNG

The first solution is that you can create an index and use the max index to find the value, click Query Editor->Add Column->Index Column.

4.PNG

After applied, you can create a measure using DAX formula:

last value = CALCULATE(MAX(Table1[Planned Value]), FILTER(Table1, Table1[Index] = MAX(Table1[Index])))

5.PNG

 

The second solution is that you can simply use “Keep Bottom Rows” to achieve last value.

 

6.PNG7.PNG8.PNG

 

Regards,

Jimmy Tao

Anonymous
Not applicable

Hi @v-yuta-msft

 

Thank you very much, I prefer the 1st solution. I tried it and it's working.

 

Thanks again

 

Regards

Ahmed

Hi @v-yuta-msft ,

 

I have read your solutions and have tried solution 1 partially. 

 

Here's how my current table looks after indexing - 

Capture1.PNG

 

DESIRED VALUE = 51.7 M

Current Calculation:

Meetings this qtr = CALCULATE(MAX(DailyMtgUsage[NUMBER_OF_MEETINGS]), FILTER('Date','Date'[Max Quarter Rank] = MAX('Date'[Max Quarter Rank])))
 
To Simplify in your format:
Last value = CALCULATE(MAX(Table2[Planned Value]), FILTER(Table2, Table2[Index] = MAX(Table1[Index])))
 
Here's how I created the index. This is a newly created measure to rank quarter start dates:
Max Qtr Start Date = MAX( 'Date'[FISCAL_QUARTER_START_DATE])
Max Quarter Rank = RANKX(ALL('Date'),[Max Qtr Start Date],,ASC,Dense)
 
I also read somewhere that MAX takes only column values and not measures. Please suggest an alternative way to do this. I tried LASTNONBLANK function but that didn't quite work.
 
Please help in retrieving the last value. I am not sure what is wrong in the dax code.
 
Thanks
Phil_Seamark
Employee
Employee

Will it always be the highest value?  If so you could use MAX([Planned Value (Cumulative)]


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Thank you @Phil_Seamark

 

But in my case it is not, it depends on other values so it is not the highest vale.

Then do you have another column that is used to determine the order to get the last value?  Is it a Date column or transaction ID


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@Phil_Seamark

No, it is not a date, it is an amount value

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.