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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
johanthedataman
Frequent Visitor

Max Value for 2 Filters

Hi there,

 

I have a question. I have the following dataset:

IDCodeOpportunityIDModifiedYearMonthStageID
142SF000020204/10/192019/045
106SF000020204/4/192019/044
105SF000020204/4/192019/044
99SF000020203/29/192019/034
98SF000020203/29/192019/033
87SF000020203/25/192019/032
86SF000020203/25/192019/032
85SF000020203/25/192019/031

 

I want to know in a calculated column: the highest StageID per Code per month. In this example, the Code is filtered on 'SF00020', but in my dataset there are much more Codes. 

 

So the solution should provide me for April StageID 5 and for March StageID 4.

 

I tried a few calculate(max(filter-options, but I couldn't solve the problem.

 

Cheers,

 

Johan

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=CALCULATE(MAX(Data[StageID]),FILTER(Data,Data[Code]=EARLIER(Data[Code])&&Data[YearMonth]=EARLIER(Data[YearMonth])))

Hope this helps.


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

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=CALCULATE(MAX(Data[StageID]),FILTER(Data,Data[Code]=EARLIER(Data[Code])&&Data[YearMonth]=EARLIER(Data[YearMonth])))

Hope this helps.


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

@johanthedataman add new measure using following expression

 

Max Stage = 
CALCULATE( 
MAX( Table4[StageID] ),
 ALLEXCEPT( Table4, Table4[Code], Table4[YearMonth] ) 
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.