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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Dax to find the range of product purchased

Hi,

I am a newbei to DAX.I have two tables as follows:

customerIDcustomername
1aaa
2bbb
3ccc
ProductIDSalesCustomerIDRangeQuantity
10003H10
10043C15
10093  
20001K20
10071C25
10021  
10052A16
10032K

18

I want to populate the Range per customer where the Quantity is the highest.Th expected output is :

customerIDcustomernameHighestrange
1aaaC
2bbbK
3cccC

Thank you in Advance!!!

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

You can create a Measure as the following.

 

HighestRange =

VAR max__ =

    MAXX (

        FILTER (

            Quantity,

            Quantity[SalesCustomerID] = MAX ( Quantity[SalesCustomerID] )

        ),

        Quantity[Quantity]

    )

RETURN

    CALCULATE ( MAX ( Quantity[Range] ), Quantity[Quantity] = max__ )

 

The result looks like this:

v-cazheng-msft_0-1620110187595.png

 

For more details, you can refer the attached pbix file.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

 

 

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

You can create a Measure as the following.

 

HighestRange =

VAR max__ =

    MAXX (

        FILTER (

            Quantity,

            Quantity[SalesCustomerID] = MAX ( Quantity[SalesCustomerID] )

        ),

        Quantity[Quantity]

    )

RETURN

    CALCULATE ( MAX ( Quantity[Range] ), Quantity[Quantity] = max__ )

 

The result looks like this:

v-cazheng-msft_0-1620110187595.png

 

For more details, you can refer the attached pbix file.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

 

 

amitchandak
Super User
Super User

@Anonymous , Create a new measure like this and use that in visual

 

Highestrange =
VAR __id = MAX ('Table'[SalesCustomerID] )
VAR __date = CALCULATE ( MAX('Table'[Quantity] ), ALLSELECTED ('Table' ), 'Table'[SalesCustomerID] = __id )
CALCULATE ( MAX ('Table'[Range] ), VALUES ('Table'[SalesCustomerID] ),'Table'[SalesCustomerID] = __id,'Table'[Quantity] = __date )

Anonymous
Not applicable

Thank you for your response!!! But I am getting the output for customer bbb highestrange = C, where as am expecting K

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.