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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Heinet
Frequent Visitor

Sum of data between two dates in another table

Hi

 

I have 2 tables, simplified like this:

 

Table 1:

 

IncidentDatapointFrom timeTo time
1A01.01.2022 12:0001.01.2022 14:00
2A01.01.2022 22:0001.02.2022.03:00
3B02.02.2022 03:0002.02.2022 05:00
4C03.02.2022 15:0004.02.2022 13:00

 

And Table 2

 

From timeTo TimeAmountDatapoint
01.01.2022 01:00 01.01.2022 02:0040A
 01.01.2022 02:0001.01.2022 03:0036A
01.01.2022 03:0001.01.2022 04:0012A
01.01.2022 04:0001.01.2022 05:0016A

 

And the table continues with amount for every 1h intervall for all datapoints.

 

Then my goal is to sum amount for each incident (in the first table) filters that sums amount with filters Table 2 (From time) <= Table 1 (From time), Table 2 (To Time) >= Table 1 (To time) and Table 1 (Datapoint) = Table 2 (Datapoint)

 

I tried with a simple Calculate(sum Table 2 Amount), Filter(Table 2, Table 2 (From time) <= Table 1 (From time) && Table 2 (To Time) >= Table 1 (To time) && Table 1 (Datapoint) = Table 2 (Datapoint)) but that didn't work. Might be some simple solution that I just can't see so would really appriciate the support

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Heinet ,

Please try to create measure with below dax formula:

Measure =
VAR cur_int =
    SELECTEDVALUE ( Table1[Incident] )
VAR cur_ft =
    SELECTEDVALUE ( Table1[From time] )
VAR cur_tt =
    SELECTEDVALUE ( Table1[To time] )
VAR cur_dp =
    SELECTEDVALUE ( Table1[Datapoint] )
VAR tmp =
    FILTER (
        ALL ( Table2 ),
        Table2[From time] <= cur_ft
            && Table2[To Time] >= cur_tt
            && Table2[Datapoint] = cur_dp
    )
RETURN
    SUMX ( tmp, [Amount] )

Add a table visual with Table1 fields and above measure

vbinbinyumsft_0-1667281828517.png

The measure is empty because there is no data to satisfy the condition.

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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

1 REPLY 1
Anonymous
Not applicable

Hi @Heinet ,

Please try to create measure with below dax formula:

Measure =
VAR cur_int =
    SELECTEDVALUE ( Table1[Incident] )
VAR cur_ft =
    SELECTEDVALUE ( Table1[From time] )
VAR cur_tt =
    SELECTEDVALUE ( Table1[To time] )
VAR cur_dp =
    SELECTEDVALUE ( Table1[Datapoint] )
VAR tmp =
    FILTER (
        ALL ( Table2 ),
        Table2[From time] <= cur_ft
            && Table2[To Time] >= cur_tt
            && Table2[Datapoint] = cur_dp
    )
RETURN
    SUMX ( tmp, [Amount] )

Add a table visual with Table1 fields and above measure

vbinbinyumsft_0-1667281828517.png

The measure is empty because there is no data to satisfy the condition.

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors