Forum Discussion

chaichatp's avatar
chaichatp
Icon for Helper III rankHelper III
7 years ago
Solved

Difference between current Date row and MIN Date row

1. I want to find the difference of the sales b/w that current row and the row of the Min Date while the same port name as well. 

2. Also, I would like to find the difference b/w current row and min date. I tried Datediff already but the problem is that i dont know what the function for current date row. 

 

Thanks.

 

DatesPorts Sales Diff of Sales between Current Date and Start of PortsDate Diff Between Curret Row and Start of the Port
3/2/2019A      20,903.00                                                                                                 (682,802.00)6634
3/2/2019B   124,942.00                                                                                                 (549,068.00)6634
3/2/2019C   462,661.00                                                                                                 (381,642.00)6634
3/2/2019D   879,744.00                                                                                                   807,788.006634
3/2/2019E   458,229.00                                                                                                 (137,630.00)6634
3/2/2019F   564,806.00                                                                                                       (2,216.00)6634
3/2/2019G   535,679.00                                                                                                   192,355.006634
3/2/2019H   509,409.00                                                                                                   425,038.006634
3/2/2019I   396,817.00                                                                                                 (488,996.00)6634
3/2/2019J   406,300.00                                                                                                   352,183.006634
2/7/2018A   953,029.00                                                                                                   249,324.006246
2/7/2018B   116,359.00                                                                                                 (557,651.00)6246
2/7/2018C   349,101.00                                                                                                 (495,202.00)6246
2/7/2018D   794,063.00                                                                                                   722,107.006246
2/7/2018E   758,795.00                                                                                                   162,936.006246
2/7/2018F   362,260.00                                                                                                 (204,762.00)6246
2/7/2018G   599,135.00                                                                                                   255,811.006246
2/7/2018H         6,308.00                                                                                                    (78,063.00)6246
2/7/2018I   907,120.00                                                                                                      21,307.006246
2/7/2018J   458,158.00                                                                                                   404,041.006246
1/1/2001A   703,705.00  
1/1/2001B   674,010.00  
1/1/2001C   844,303.00  
1/1/2001D      71,956.00  
1/1/2001E   595,859.00  
1/1/2001F   567,022.00  
1/1/2001G   343,324.00  
1/1/2001H      84,371.00  
1/1/2001I   885,813.00  
1/1/2001J      54,117.00  
  • Hi chaichatp ,

    For your requirement, please create the measure below.

    1. I want to find the difference of the sales b/w that current row and the row of the Min Date while the same port name as well. 

    slaes for mindate =
    CALCULATE (
        MAX ( 'table'[ Sales ] ),
        FILTER (
            ALLEXCEPT ( 'table', 'table'[Ports] ),
            'table'[Dates] = MIN ( 'table'[Dates].[Date] )
        )
    )
    Diff of Sales between Current Date and Start of Ports = CALCULATE(MAX('table'[ Sales ]))-[slaes for mindate]

    2. Also, I would like to find the difference b/w current row and min date. I tried Datediff already but the problem is that i dont know what the function for current date row. 

    mindate =
    CALCULATE ( MIN ( 'table'[Dates] ), ALLEXCEPT ( 'table', 'table'[Ports] ) )
    Date Diff Between Curret Row and Start of the Port = DATEDIFF([mindate],CALCULATE(MAX('table'[Dates])),DAY)

    Here is the output.


    Hope this can help you!
    Best  Regards,

    Cherry

1 Reply

  • v-piga-msft's avatar
    v-piga-msft
    Icon for Resident Rockstar rankResident Rockstar

    Hi chaichatp ,

    For your requirement, please create the measure below.

    1. I want to find the difference of the sales b/w that current row and the row of the Min Date while the same port name as well. 

    slaes for mindate =
    CALCULATE (
        MAX ( 'table'[ Sales ] ),
        FILTER (
            ALLEXCEPT ( 'table', 'table'[Ports] ),
            'table'[Dates] = MIN ( 'table'[Dates].[Date] )
        )
    )
    Diff of Sales between Current Date and Start of Ports = CALCULATE(MAX('table'[ Sales ]))-[slaes for mindate]

    2. Also, I would like to find the difference b/w current row and min date. I tried Datediff already but the problem is that i dont know what the function for current date row. 

    mindate =
    CALCULATE ( MIN ( 'table'[Dates] ), ALLEXCEPT ( 'table', 'table'[Ports] ) )
    Date Diff Between Curret Row and Start of the Port = DATEDIFF([mindate],CALCULATE(MAX('table'[Dates])),DAY)

    Here is the output.


    Hope this can help you!
    Best  Regards,

    Cherry