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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DataNinja777
Super User
Super User

Address of the customer with maximum sales within the same customer hierarchy group

Hi Power BI Community,

 

I'd like to show the highest AR balance customer address included in the customer group hierarchy.  The issue is that the customer hierarchy contains multiple locations (addresses) for a single group customer, and concatenated address becomes too long. In order to simplify the disclosure, I'd like to show the address of the customer code (contained in the aggregated higher customer hierarchy group), which has the highest amounts of accounts receivable.  I've written the following dax formula to achieve the aforementioned output, but the concatenated customer address is for multiple locations instead of the top 1.  

 

DataNinja777_1-1710598729183.png

The name of the customer and the aggregated value of the accounts receivable contains the multiple location (address) information for one aggregated row, but for address, I'd like to show only the highest address as it gets too long for the concatenated result.   

 

Thank you for your help!

 

 

 


 

1 ACCEPTED SOLUTION
AmiraBedh
Super User
Super User

Since you didn't share any data/data model I am assuming the following (please copy/paste your code as text and do not add it as an image) .

I used HighestARAddress to calculate the address with the highest AR balance and with the TOPN to return the top address based on the [AR by customer] measure.
Once out of the top 1 selected, you extract the address itself. MAXX is used here to pull the actual address string, but since TOPN is limited to 1, it effectively grabs the address of the highest AR.
And finally the ALL to ignore any filter context that might limit the addresses considered outside of this calculation.

Highest AR Address =
VAR HighestARAddress = CALCULATE(
    MAXX(
        TOPN(
            1, 
            VALUES(Customer[Address]), 
            [AR by customer], 
            DESC
        ), 
        Customer[Address]
    ),
    ALL(Customer)
)
RETURN
HighestARAddress

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

4 REPLIES 4
DataNinja777
Super User
Super User

Thank you @AmiraBedh .  In fact, the reason my formula didn't work yesterday was due to the fact that the measure I was referencing as an order by measure was incorrect, and both your measure and mine produced the same highest sales customer address after changing that part.  

Glad to help 🙂


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
Wilson_
Super User
Super User

Hi DataNinja77,

 

Can you please share a sample pbix file? (If you don't know how, please check the pinned thread in the forum.) It would make debugging your issue easier. 🙂




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

Proud to be a Super User!





AmiraBedh
Super User
Super User

Since you didn't share any data/data model I am assuming the following (please copy/paste your code as text and do not add it as an image) .

I used HighestARAddress to calculate the address with the highest AR balance and with the TOPN to return the top address based on the [AR by customer] measure.
Once out of the top 1 selected, you extract the address itself. MAXX is used here to pull the actual address string, but since TOPN is limited to 1, it effectively grabs the address of the highest AR.
And finally the ALL to ignore any filter context that might limit the addresses considered outside of this calculation.

Highest AR Address =
VAR HighestARAddress = CALCULATE(
    MAXX(
        TOPN(
            1, 
            VALUES(Customer[Address]), 
            [AR by customer], 
            DESC
        ), 
        Customer[Address]
    ),
    ALL(Customer)
)
RETURN
HighestARAddress

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors