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

sum of max value per category

Hi, 

 

I need some help to write a DAX formula, I've tried so many already that I get lost now 😞 

Here is what I need as a final result, correct numbers are in green, wrong ones are the red (what I have for the moment) : 

DateDestinationNumber of available trainsLimit per daypercentage (number of available trains/limit per day)
18/08/2021BELVAL3100.3
19/08/2021BELVAL2100.2
18/08/2021MERTERT3500.06
19/08/2021MERTERT4500.08
Total 12100  1200.12    0.1

 

Global percentage : 0.1

 

My problem is to retrieve the correct Total of limit per day. Instead of having 120, I have 100 because I put a max(limit per day) to get the limit for each row. Here are how my data look like in the table : 

date                 |   train  |  destination |  limit    

18/08/2021     |  T1       |    BELVAL     |  10

18/08/2021     |  T2       |    BELVAL     |  10

18/08/2021     |  T3       |    BELVAL     |  10 

19/08/2021     |  T1       |    BELVAL     |  10

19/08/2021     |  T2       |    BELVAL     |  10

18/08/2021     |  T4       |    MERTERT  |  50

18/08/2021     |  T5       |    MERTERT  |  50

18/08/2021     |  T8       |    MERTERT  |  50

19/08/2021     |  T6       |    MERTERT  |  50

19/08/2021     |  T4       |    MERTERT  |  50

19/08/2021     |  T5       |    MERTERT  |  50

19/08/2021     |  T7       |    MERTERT  |  50

 

Can you please help me to get the green result instead of the red one ? Huge thanks for your help!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi amitchandak, 

 

Thanks for your answer but the 2 formulas don't bring the correct results 😕 It's weird you don't have the destination field in your formulas isn't it ?

However, I finally managed to write a formula that seems OK, can you please give me your feeling on it ?

M_percentagelimit =
VAR nbdays = countrows('DimDate')
VAR pct = sumx(
                         summarize(Disponibilite,Disponibilite[destination],"_1",max(Disponibilite[limit]))
                         ,[_1])
                        * nbdays
RETURN nb

Thanks, AnSo

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Use these two measures for the last 2

 

sumx(summarize(Table,[date], [train],[limit]), [Limit])

 

sumx(summarize(Table,[date], [train],"_1", divide(countrows(Table),max(Table[Limit]))), [_1])

Anonymous
Not applicable

Hi amitchandak, 

 

Thanks for your answer but the 2 formulas don't bring the correct results 😕 It's weird you don't have the destination field in your formulas isn't it ?

However, I finally managed to write a formula that seems OK, can you please give me your feeling on it ?

M_percentagelimit =
VAR nbdays = countrows('DimDate')
VAR pct = sumx(
                         summarize(Disponibilite,Disponibilite[destination],"_1",max(Disponibilite[limit]))
                         ,[_1])
                        * nbdays
RETURN nb

Thanks, AnSo

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.

Top Solution Authors