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
FeezaAga
Helper I
Helper I

How to find sum of max values in a column and filter it?

I have a table that has mutiple values of "OPCount" as rows for each Faciliy name and each date. So i am summing them up to show the max for each day for each facilty. 

Below is what i am using to summarize my rows(Please tell me if this is correct):

1OPCount =
IF(
 
-- NORMAL LINE---
MAXA(Query1[OPCount]),
-- TOTAL LINE ---
SUMX(
VALUES('Query1'[InvDate1]),
CALCULATE(
MAXA(Query1[OPCount])
)
)
)

This is how i get my values - ie: max of among the rows. Butt, I need it to show as total of each column.

 

FeezaAga_1-1598343353851.png

FeezaAga_2-1598343485988.png

 
 
Can you'll suggest a better way to do this so that i clearly get the total of each column whatever filter i may use?
2 ACCEPTED SOLUTIONS

Hi @FeezaAga ,

 

To what I can understand from your data and the result you present is that the values you are picking up are the maximum values for each day correct?

 

I added a new value of 5 to facility A and day 1 in order to get two values for the same date:

MFelix_0-1598449476623.png

Then I made some changes to the measure adding the factory to the sumx:

 

1OPCount =
IF (
    HASONEFILTER ( 'Query1'[EachDay of month ] );
    MAX ( 'Query1'[OPCount] );
    SUMX (
        SUMMARIZE (
            'Query1';
            'Query1'[EachDay of month ];
            Query1[FacilityName];
            "@Max"; MAX ( 'Query1'[OPCount] )
        );
        [@Max]
    )
)

When making use of aggregate functions you need to refer to the columns you need, in this case the result of the summarize table is a table that picks up the value for each facility and each day and a single value for the OPCount.

Having the previous syntax what you are getting is a table with days and a value per each day so you only get the 551 has you final result, that is the higher value at the day level.

 

Check image below and PBIX file attach.

MFelix_1-1598449853037.png

As you can see on facility A day 1 i have 11 and the 5 is not consider and if you sum all the days that are presented you get 1.093.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Hi @FeezaAga ,

 

Has refered measures are based in context when in the syntax is refered HASONEFILTER(Table[EachDay]) means that it will check if there is a single value selection for EachDay son when it has one day then it will give MAX other wise is the sum of the values.

When you are filtering on a single day the HASONEFILTER is always true so returns always the maximum value and not the sum try to make the following change to your measure:

1OPCount = 
IF (ISINSCOPE(Query1[EachDay of month ]);
    MAX ( 'Query1'[OPCount] );
   SUMX (
        SUMMARIZE (
            'Query1';
            'Query1'[EachDay of month ];
            Query1[FacilityName];
            "@Max"; MAX ( 'Query1'[OPCount] )
        );
        [@Max]
    )
)

 

Check PBIX file attach:

MFelix_0-1598527693475.png

MFelix_1-1598527716837.png

 

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

11 REPLIES 11

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.