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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX formulae to get maximum value based on column from different table

Hi All,
What I need is Sum of values of each category where category is one table and value is in another. Here is the ex:
Table 1:
ID      Category
1             A
2             B
3             C

 

Table 2:
ID           Value
1               10

1               20

1               10

2               10

3                 5

 

So as above: Category A has total value 40 and Category B has 10 and Category C has 5
I need to show in a card the Category Name with Highest Value. How can I do this?

Thanks,

Ankku

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please try this measure:

Top Category = MAXX(TOPN(1,VALUES(Table1[Category]),CALCULATE(Sum(Table2[Value])),DESC),Table1[Category])
 
And see the expected output in below screen shot:
Capture.JPG
 
Please give KUDOS for support  and also accept this as a SOLUTION if it helps you!
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

7 REPLIES 7
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

The relationship between tables:

b9.PNG

 

Create a measure:

// Measure
maximum value = 
 CALCULATE(
     SUM('Sheet3 (2)'[ Value]),
     ALLEXCEPT(
         'Sheet3 (2)',
         'Sheet3 (2)'[ID          ], Sheet4[Category]
     )
)

 

Add a card visual:

b10.PNG

 

Is tihs what you want?

 

Best regards,
Lionel Chen

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



 

 

 

Anonymous
Not applicable

Hi Lionel Chen,

@v-lionel-msft 

 

Thanks for response but this is not what I want. I am able to get the maximum value for each category but now in the card visual I should show only that category which is maximum of three. If I add this measure in Card visual it will give me the sum of values while what I am looking for is to display the category which will be have maximum value.

 

Thanks, Ankku

Hi @Anonymous ,

 

After creating a relationship between those two tables as mentioned by @v-lionel-msft . You can just create one measure like below:

Measure = Max(Table[Values])

And take Card visual (Single Card) from visualization pane and drag this measure.

 

Give me some time i will try to replica your issue at my side and will post output in some time.

Please give KUDOS for support and accept this as a solution if it helps you!

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

Hi @Tahreem24 

 

That will be the maximum value on my card visual not the category name which has the maximum value

I need the category name in my card visual. In this example, My card visual should show Category A because it has value 40 which is greater than Category B and Category C.

Hi @Anonymous ,

 

Please try this measure:

Top Category = MAXX(TOPN(1,VALUES(Table1[Category]),CALCULATE(Sum(Table2[Value])),DESC),Table1[Category])
 
And see the expected output in below screen shot:
Capture.JPG
 
Please give KUDOS for support  and also accept this as a SOLUTION if it helps you!
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

Bravo!!!!

@Anonymous , Sorry for misundertood your problem earlier. Later I realized your proper statement.

Good Luck!!!

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.