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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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