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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nissa23
Frequent Visitor

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

1 ACCEPTED SOLUTION
v-tianyich-msft
Community Support
Community Support

Hi @Nissa23 ,

 

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

vtianyichmsft_0-1713320889877.png

 

vtianyichmsft_1-1713320898847.png

 

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.

View solution in original post

4 REPLIES 4
v-tianyich-msft
Community Support
Community Support

Hi @Nissa23 ,

 

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

vtianyichmsft_0-1713320889877.png

 

vtianyichmsft_1-1713320898847.png

 

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.

Thank you very much @_AAndrade .

It's working.

Regards,

_AAndrade
Super User
Super User

Hi @Nissa23,

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





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




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 bellowPicture.png

Hope its will help you to understand the issue.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.