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
chudson
Helper IV
Helper IV

Return MAX of a Distinct Count per Category

Hi,

 

See the below visual table I have.  I'm trying to created a measure where I can remove the "SubSet" column from my visualization and return the maxium of the count column for each Set Category.  See example for current and desired.

 

Current

SetSubSetCount
AA.11
AA.23
AA.32
AA.41
BB.11
BB.21
BB.34
CC.13
CC.21

 

Desired (remove Subset and have return a value of the max count for reach Set category)

 

SetMax of Subset Counts
A3
B4
C3

 

Thanks,

1 ACCEPTED SOLUTION

Hi,

 

Try this calculated column formula

 

=CALCULATE(MAX(Data[Total]),FILTER(Data,Data[customername]=EARLIER(Data[customername])&&Data[SetFamily]=EARLIER(Data[SetFamily])))

 

Hope this helps.


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

View solution in original post

12 REPLIES 12
Hydramh2
Frequent Visitor

Hi , can I ask how you wrote the Desire column?

Which measure did you use?

I want to replicate a similar column in my report but I'm not able to do that. Thanks

Hi,

It is not a measure - it is a calculated column formula.


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

Hi @Hydramh2

 

Below are 2 versions of calculated columns I used.  You would obviously have to swap in the right fields and names for yours but you can see the DAX i used.

 

CALCULATE(MAX('SET CONTROL HISTORY'[SetTypeCount]),FILTER('SET CONTROL HISTORY','SET CONTROL HISTORY'[customername]=EARLIER('SET CONTROL HISTORY'[customername])&&'SET CONTROL HISTORY'[SETFAMILY]=EARLIER('SET CONTROL HISTORY'[SETFAMILY])))

 

SUMX(FILTER('SET CONTROL HISTORY','SET CONTROL HISTORY'[customername]=EARLIER('SET CONTROL HISTORY'[customername])&&'SET CONTROL HISTORY'[SetTypeDesc]=EARLIER('SET CONTROL HISTORY'[SetTypeDesc])),'SET CONTROL HISTORY'[Count1])

 

edhans
Super User
Super User

In the visual for a Table, add the Set field to values. Create this measure:

Max Set Count = MAX(TableData[Count])

Add that measure to the values.

 

Change the table name "tableData" to whatever your table name is.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi @edhans,

 

The Count column is a count of subset in a table visualization, both those tables are already in visulizations but I need a measure to get the max of each.

 

Thanks,

Then use MAX(YourCountMeasure)

 

IF that isn't what you need, then please post sample data or CLEARLY explain what everything is. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

I tried to attach a dummy data set but apparently I cannot since I'm only a regular forum user.  Below is a pivot from my dataset replicating a table visulization (dummied down since my dataset is really thousands of lines).  I basically want to create either a calculated measure or column that will give me the max of the "Total" column by SetFamily per customer from looking at the setdescription. 

 

I want the largest of the total # from the set descriptions under each set family by customer.

I just don't know the perfect DAX to get to this.  Once I have that calculation I want to remove the setdescription from my visual so it only shows the Customer, SetFamily & Max Count column I just have those in there so you can understand my desired result based on the data.

 

Let me know if this makes sense.

 

customernameSetFamilySetDescriptionTotalDesire Max result for setfamily by setdescription
Customer1IC1IC1 SET 633
Customer1IC1IC1 SET123
Customer1IC1IC1 SET223
Customer1IC1IC1 SET323
Customer1IC1IC1 SET433
Customer2AVAAVA SET33
Customer2BAT3BAT SET533
Customer2IC1IC1 SET 636
Customer2IC1IC1 SET136
Customer2IC1IC1 SET226
Customer2IC1IC1 SET336
Customer2IC1IC1 SET466
Customer2NCPNCP SET 133
Customer2NCPNCP SET 213
Customer2NCPNCP SET 313
Customer2NSDNSD SET 133
Customer2NSDNSD SET 213
Customer2TLXTLX SET 133

 

Thanks,

Hi @chudson , can I ask you how you wrote the Desire column?

Which measure did you use?

I want to replicate a similar column in my report but I'm not able to do that. Thanks

Hi,

 

Try this calculated column formula

 

=CALCULATE(MAX(Data[Total]),FILTER(Data,Data[customername]=EARLIER(Data[customername])&&Data[SetFamily]=EARLIER(Data[SetFamily])))

 

Hope this helps.


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

Hi @Ashish_Mathur,

 

Yeah this worked as a calculated column.  Is that the only way or is there a measure that can be done to get this result?

Hi,

 

Try these measures

 

Measure=SUM(Data[Total])

Max=MAXX(ALL(Data[SetDescription]),[Measure])

 

Hope this helps.


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

If your visual has Customer and Set in it, then just =MAX(tablename[Total]) will work as Customer and Set will provide the filter context for it.

 

If not then you'd need to do something along the lines of this (typing free hand here, so check the syntax)

=
CALCULATE(
    MAX(tablename[Total],
    ALLEXCEPT(tablename,[Customer],[Set])
)

No matter what you put in the table visual now, it will get the MAX value of TOTAL taking customer and set into account, but ignore anything else.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.