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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bagabo
Frequent Visitor

Getting City with highest sum of hours per customer

Hi there!

As in the subject, i'm currently searching for a formula to get the city with the highest sum of hours per customer.
So in the example, the customer has a variety of hours in the citys "Hamburg", "Kiel", "Rostock" and "Ruhr". But i want to find the City with the maximum sum of hours and write that into a new column for every customer.

Screenshot 2021-09-08 112326.png

So in this example, if he hast the most hours in "Hamburg", in every of the rows in the new column should be "Hamburg".
I tried a lot of things, but either it didn't work as planned or i get confusing errors like "circular dependency".

Thanks in advance!

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

Hi, @bagabo ;

You could try create columns as follows:

RANK = 
RANKX ( 'Table',
        CALCULATE (
            SUM ( [Total Time and Work] ),
            ALLEXCEPT ( 'Table', 'Table'[WC Employee], 'Table'[Niederlassung] )),,ASC,DENSE)
highest =
CALCULATE (
    MAX ( [Niederlassung] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[WC Employee] ),
        [RANK]= CALCULATE ( MAX ( [RANK] ), ALLEXCEPT ( 'Table', 'Table'[WC Employee] ) )))

Another method is create a column or a measure.

Highest2 =
CALCULATE (
    MAX ( [Niederlassung] ),
    FILTER (ALLEXCEPT ( 'Table', 'Table'[WC Employee] ),
        CALCULATE (SUM ( [Total Time and Work] ),ALLEXCEPT ( 'Table', 'Table'[WC Employee], 'Table'[Niederlassung] ))
            = MAXX ( ALLEXCEPT ( 'Table', 'Table'[WC Employee] ),
                CALCULATE ( SUM ( [Total Time and Work] ),ALLEXCEPT ( 'Table', 'Table'[WC Employee], 'Table'[Niederlassung] ) ))))

The final output is shown below:

vyalanwumsft_0-1631500282259.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Why do you want to create a calculated column formula for this?  Why not a measure?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yalanwu-msft
Community Support
Community Support

Hi, @bagabo ;

You could try create columns as follows:

RANK = 
RANKX ( 'Table',
        CALCULATE (
            SUM ( [Total Time and Work] ),
            ALLEXCEPT ( 'Table', 'Table'[WC Employee], 'Table'[Niederlassung] )),,ASC,DENSE)
highest =
CALCULATE (
    MAX ( [Niederlassung] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[WC Employee] ),
        [RANK]= CALCULATE ( MAX ( [RANK] ), ALLEXCEPT ( 'Table', 'Table'[WC Employee] ) )))

Another method is create a column or a measure.

Highest2 =
CALCULATE (
    MAX ( [Niederlassung] ),
    FILTER (ALLEXCEPT ( 'Table', 'Table'[WC Employee] ),
        CALCULATE (SUM ( [Total Time and Work] ),ALLEXCEPT ( 'Table', 'Table'[WC Employee], 'Table'[Niederlassung] ))
            = MAXX ( ALLEXCEPT ( 'Table', 'Table'[WC Employee] ),
                CALCULATE ( SUM ( [Total Time and Work] ),ALLEXCEPT ( 'Table', 'Table'[WC Employee], 'Table'[Niederlassung] ) ))))

The final output is shown below:

vyalanwumsft_0-1631500282259.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Awesome! This works just fine! Thank you very much

amitchandak
Super User
Super User

@bagabo , Assume you have a measure for total hours as hours,

you can create a rank like this and filter that =1 in visual level filter

 

rankx(filter(allselected(Table[City], Table[Customer]), [Customer] = max([customer])), [hours],,desc,dense)

Unfortunately, i cannot Filter this, cause I need also the data of the other cities, they should all summarize in the largest city.

I tried using 

LOOKUPVALUE(i3_Report[Niederlassung bereinigt];i3_Report[SUM p NL p CSE];MAX(i3_Report[SUM p NL p CSE]))

Where "SUM p NL p CSE" ist the sum of total hours per customer per city, but the problem is that it takes just the max value of this column, not the max value per customer. 




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.