Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX max value by category

Hello, I have this measure to calculate the maximum number of passengers per train and per date. I would like to keep only one line per train, which keeps only the line of the date with the highest value for each train. I can do it by filtering on my rank column but we would like to succeed in DAX. 

 



thanks !!

  • Hi Anonymous ,

     

    Try the following formula:

     

    Measure = 
    var Maxium = 
    MAXX(
        ALL('Tab_FQ_Emport Max Train Jour'[date]),
        CALCULATE(SUM('Tab_FQ_Emport Max Train Jour'[Emport_Max_Train_Jour]))
    )
    return 
    IF( SUM('Tab_FQ_Emport Max Train Jour'[Emport_Max_Train_Jour]) = Maxium, Maxium )

       

     

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

    Best Regards,
    Winniz

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

3 Replies

  • That means that you only want to display the train column, and then you need separate measures for the date of max occupancy for each train, and then occupancy number for that train and date.

  • v-kkf-msft's avatar
    v-kkf-msft
    Community Support

    Hi Anonymous ,

     

    Try the following formula:

     

    Measure = 
    var Maxium = 
    MAXX(
        ALL('Tab_FQ_Emport Max Train Jour'[date]),
        CALCULATE(SUM('Tab_FQ_Emport Max Train Jour'[Emport_Max_Train_Jour]))
    )
    return 
    IF( SUM('Tab_FQ_Emport Max Train Jour'[Emport_Max_Train_Jour]) = Maxium, Maxium )

       

     

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

    Best Regards,
    Winniz

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

  • Hi,

    Share some data (in a format that can be pasted in MS Excel) and show the expected result.