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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Retreiving the latest value from a table

Hi!
I am trying to pull out the latest value, substract it from a fixed value in other table, and display the result. I only just started DAX and would appreciate help with the probably very simple task...

 

Table1 has three basic columns and a couple of thousand rows:

Index  - Unique integer

Time - Recorded time in time format

Value1 - Decimal value

 

Table2 has a contant value2.

 

The simple result I am looking for is hence something like LatestTotal = (Latest) Value1 - Value2.

 

Thanks!

 

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @Anonymous 

is there any relationships between table1 and table2?

anyway, try a measure

LatestTotal = 
var lastDataTbl1 = calculate(max('Table1'[Time]);ALL('Table1'))
var lastDataTbl2 = calculate(max('Table2'[Time]);ALL('Table2'))
RETURN 
calculate(
SUM('Table1'[Value1]); FILTER(ALL('Table1');'Table1'[Time]=lastDataTbl1)
) - 
calculate(
SUM('Table2'[Value2]); FILTER(ALL('Table2');'Table2'[Time]=lastDataTbl2)
)

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Many thanks all for your input!

Ashish_Mathur
Super User
Super User

Hi,

Does this measure work

=MAX(Table1[Value1])-MAX(Table2[Value2])


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

You can create a formula like below to get the values from table 2 to table 1 if there are any filters. Else you can take max from table2 and put in table one. In both case it is a new Column; not measure

 

New Column = maxx(filter(table2,table2[Col1]= table1[col1] && table2[Col2]= table1[col2]  ),table2[required_col])

You can change the joins as per need. The table need not have these join in the relationship.

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
az38
Community Champion
Community Champion

Hi @Anonymous 

is there any relationships between table1 and table2?

anyway, try a measure

LatestTotal = 
var lastDataTbl1 = calculate(max('Table1'[Time]);ALL('Table1'))
var lastDataTbl2 = calculate(max('Table2'[Time]);ALL('Table2'))
RETURN 
calculate(
SUM('Table1'[Value1]); FILTER(ALL('Table1');'Table1'[Time]=lastDataTbl1)
) - 
calculate(
SUM('Table2'[Value2]); FILTER(ALL('Table2');'Table2'[Time]=lastDataTbl2)
)

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

HI @Anonymous ,

 

Can you give us some sample data and the expected results of the same?

 

This will help us to answer your question quickly.

 

-Tejaswi

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.