Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

How can i write dax for same version no for max line no and vice verse

How can i write dax for same version no for max line no.
and 
How can i write dax for different version no for same line no.
 

Hi Everybody,

 

I want to add the yellow line mark amount. How to do it in dax. Is there anyone to help me.

 

 

2 Replies

  • MAwwad's avatar
    MAwwad
    Icon for Solution Sage rankSolution Sage

     

    To get the amount for the maximum line no for each version, you can use the following DAX formula:

     

     
    Max Line Amount = CALCULATE( SUM('Table'[Amount]), FILTER( 'Table', 'Table'[Version No] = EARLIER('Table'[Version No]) && 'Table'[Line No] = MAX('Table'[Line No]) ) )
     

    Here, we are using the CALCULATE function to filter the table based on two conditions - same version no and maximum line no. The EARLIER function is used to refer to the current row in the filter context, and the MAX function is used to get the maximum line no for the current version. Finally, we sum up the Amount column for the filtered rows.

    To get the amount for different version nos for the same line no, you can use the following DAX formula:

     

     
    Same Line Amount = CALCULATE( SUM('Table'[Amount]), FILTER( 'Table', 'Table'[Line No] = EARLIER('Table'[Line No]) && 'Table'[Version No] <> EARLIER('Table'[Version No]) ) )
     

    Here, we are using the CALCULATE function to filter the table based on two conditions - same line no and different version no. The EARLIER function is used to refer to the current row in the filter context, and the <> operator is used to check for inequality between version nos. Finally, we sum up the Amount column for the filtered rows.

  • Anonymous's avatar
    Anonymous
    Not applicable

    This is not working properly. there is both condition which is should be one value.