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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Nuemio
Frequent Visitor

Retrieve max value per id

Hi there,

 

I'm running into a slight issue, I'm trying to return the maximum period that occurs for each company id. 
For example a companyid of 17001 should return a maximum period of 2305 and a company id of 41001 should return 2306. 

 

I'm trying to do this via a calculated column. So far using Max() returns the maximum period in the entire dataset

 

Nuemio_0-1688645650108.png

Any tips would be appreciated

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Dhairya
Solution Supplier
Solution Supplier

Hey @Nuemio 
I download your dataset and tried the same DAX code I provided in the above reply, it worked perfectly

I tested by filtering two CompanyID "14001" and "47099" 

Dhairya_0-1688727912330.png

If you are still facing the issue then please share the DAX code you used for creating calculated column

View solution in original post

4 REPLIES 4
Dhairya
Solution Supplier
Solution Supplier

Hey @Nuemio 

I tried to recreate your scenario I have taken the following table as input

Dhairya_0-1688646510259.png

Now, I have used follow DAX formula for creating a calculated column

Max period by company =
CALCULATE ( MAX ( TableA[Period] ), ALLEXCEPT ( TableA, TableA[CompanyID] ) )

I have got the following output, which will fulfill your requirements.

Dhairya_1-1688646683481.png


If it helps you then Please mark my solution as accepted so that others can find it quickly when they face a similar issue. Thank you!

Hi Dhairya, 

 

Thanks for getting back, however this proposed solution doesn't work and still returns the maximum period regardless of company id.

Attached is an export of the dataset:

 

https://docs.google.com/spreadsheets/d/1gbwXZ3SP0yG0bBv642C4IaNgsGGTEeHi/edit?usp=sharing&ouid=11725...

 

 

Thank you!

Nuemio

Dhairya
Solution Supplier
Solution Supplier

Hey @Nuemio 
I download your dataset and tried the same DAX code I provided in the above reply, it worked perfectly

I tested by filtering two CompanyID "14001" and "47099" 

Dhairya_0-1688727912330.png

If you are still facing the issue then please share the DAX code you used for creating calculated column

Thanks Dhairya,

The issue I was getting was because I was using the FILTER() expression for a particular actuality code in the calculate which wasn't necessary. Your solution solved my problem!

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.