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
dhirendra59
Helper I
Helper I

Need help with Dax - calculate (pull) a value based on max date time aggregate to certain fields

question1.JPG

 

Hello All, I need help to create a measure to pull total on hand balance value agregated by warehouse and item number based on max date-time for that particular day with filter transaction type 10. 

 

It should give value 1547 for 7/27, 1576 for 7/28 and 1631 for 7/29 and so on. 

 

Please let me know if you need more information. See attached data

warehouseitem_numberstock_transaction_typetransaction_identitytotal_on_hand_balancetransaction_datetime
7002011510WOP15477/27/2020 7:37
7002011510WOP14387/27/2020 7:38
7002011510WOP16537/27/2020 7:38
7002011510WOP15767/28/2020 8:28
7002011531OID16357/28/2020 15:06
7002011531OID16177/28/2020 15:12
7002011510WOP16407/29/2020 7:19
7002011511WOM16317/29/2020 8:47
7002011531OID15587/29/2020 10:34
7002011531OID15407/29/2020 10:36
7002011531OID15227/29/2020 15:23
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@dhirendra59 , Have date column and try

 

date = [transaction_datetime].date

new measure = calculate(lastnonblankvalue(table[transaction_datetime],min(table[total_on_hand_balance])),allexcept(Table,Table[warehouse],Table[item_number], Table[transaction_identity], Table[Date]), Table[stock_transaction_type]=10)

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@dhirendra59 , Have date column and try

 

date = [transaction_datetime].date

new measure = calculate(lastnonblankvalue(table[transaction_datetime],min(table[total_on_hand_balance])),allexcept(Table,Table[warehouse],Table[item_number], Table[transaction_identity], Table[Date]), Table[stock_transaction_type]=10)

Thank you so much @amitchandak 

Greg_Deckler
Super User
Super User

@dhirendra59 - Seems like either a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.

 

Or perhaps Lookup Min/Max: https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814?search-action-id=1...


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