Forum Discussion

Nissa23's avatar
Nissa23
Icon for Helper I rankHelper I
2 years ago
Solved

Calculate sum() according to a date range

Hello,

Here is a sample of my table :

IDNameStart_dateEnd_date  Currentvalue
1A1999-01-012999-01-01   115
2B1999-01-012023-03-22   010
3B2023-03-222999-01-01   120
4C1999-01-012999-01-01   135
5D1999-01-012023-06-25   010
6D2023-06-252999-01-01163

I have a linked table that contains a date : Validate_date

I want to calculate a SUM(Value) where valide_date falls between Start and End_date.

For Example : for 😧 if Validate_date is between 1999-01-01 & 2023-06-25 I use 10 in the calculated measure, otherwise, 63.

I've tried to calculate a new column as follow :

 

Total_Value = 
IF (SELECTEDVALUE('Tabl1'[Validate_date]) >= SELECTEDVALUE(Tab2[Start_date]) && SELECTEDVALUE('Tabl1'[Validate_date])<SELECTEDVALUE((Tab2[End_date]),1,0)
)

 

I got only 0 . So doesn't work.

Can anyone help on how to calculate this measure?

Thanks a lot.

Nissa

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Nissa23 ,

     

    I made simple samples and you can check the results below:

     

     

    An attachment for your reference. Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

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

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Nissa23 ,

     

    I made simple samples and you can check the results below:

     

     

    An attachment for your reference. Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

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

  • _AAndrade's avatar
    _AAndrade
    Icon for Resident Rockstar rankResident Rockstar

    Hi Nissa23,

    Could you please share a picture of your validate_date table and the relationship between both tables?

    • Nissa23's avatar
      Nissa23
      Icon for Helper I rankHelper I

      Hi _AAndrade 

      My model is a bit complicated. I've tried to built a sample of my data in order to simplify the problem.

      The relationship between the 2 tables is is as shown bellow

      Hope its will help you to understand the issue.