cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
faint127
Frequent Visitor

Get Max Value per category (Power Query)

Hey Guys!

 

So, i have this two tables

 

Screenshot_2.jpg

I want to create a table (Table C) witch results in Table A and Table B join (Date, Category).

 

Screenshot_4.jpg

It sounds easy, but i started using Power Query recently, so i still have some difficulties, especially in retrieving "Last Date With Data "in order to get the last amount reported by date / category.

 

I don't know if i managed to explain all correctly, but here is the DAX formula i've used to obtain succefully the two columns:

 

 

Date With Data (Hidden Aux) =
VAR CurrentDate = TableC[Date]
RETURN
CALCULATE (
MAX (TableC[Table B Date]),
FILTER (
Table C,
TableC[Category] = EARLIER ( TableC[Category] )
&& TableC[Date] <= CurrentDate ) )


Amount A =
var CurrentDate = Table C[Date With Data (Hidden Aux)]
return
CALCULATE (
MAX ( TableB[Amount])+0,
FILTER (
TableB,
TableB[Category] = EARLIER ( TableC[Category] )
&& TableB[Date] = CurrentDate ) )

 

 
 

Thanks in advance! 

 

 
 
1 REPLY 1
camargos88
Community Champion
Community Champion

Hi @faint127 ,

 

Check this file as an example: Download PBIX 

 

I've used Power Query to merge em fill down the null values.

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors