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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Calculated Column IF condition to get Average Data from One Table on to Another Table

Hi All,

 

I have two tables, joined at on Date with Many to Many cardinalities. 'Table A' has the data in 5 minutes buckets and 'Table B' has the data at a minute level. I want to compare the 'Time_IN' from 'Table B' with StartTime and EndTime from Table A' to get the average of 'Info_Value' for every 5 minutes from 'Table B' on to 'Table A'

 

TABLE A

DateStartTimeEndTime
01/19/20 ||  01/19/20 10:00:00 ||  01/19/20 10:05:00
01/19/20 ||  01/19/20 10:05:00 ||  01/19/20 10:10:00
01/19/20 ||  01/19/20 10:10:00 ||  01/19/20 10:15:00
01/20/20 ||  01/19/20 10:15:00 ||  01/19/20 10:20:00

 

TABLE B

DateTime_INInfo_Value
1/19/20 ||  1/19/20 10:00:00 ||  3
1/19/20 ||  1/19/20 10:01:00 ||  4
1/19/20 ||  1/19/20 10:02:00 ||  5
1/19/20 ||  1/19/20 10:03:00 ||  6
1/19/20 ||  1/19/20 10:04:00 ||  11
1/19/20 ||  1/19/20 10:05:00 ||  12
1/19/20 ||  1/19/20 10:06:00 ||  10

The Dax query I wrote is giving the overall average of Table B

NEW_Column = IF(
COUNTROWS(
FILTER(Table B, 'Table B'[timeIN] >= 'Table A'[start_date_time] && 'Table B'[timeIN] <= 'Table A'[End_date_time])) > 0, AVERAGE('Table B'[Info_Value]))


Expected Output

DateStartTimeEndTimeNew_Column
01/19/20 ||  01/19/20 10:00:00 ||  01/19/20 10:05:00 ||     8.2
01/19/20 ||  01/19/20 10:05:00 ||  01/19/20 10:10:00  ||    ...
01/19/20 ||  01/19/20 10:10:00 ||  01/19/20 10:15:00 ||     ...
01/20/20 ||  01/19/20 10:15:00 ||  01/19/20 10:20:00 ||     ...

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try a new column in table A Like

AVERAGEX(FILTER(Table B, 'Table B'[timeIN] >= 'Table A'[start_date_time] && 'Table B'[timeIN] <= 'Table A'[End_date_time]),'Table B'[Info_Value])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try a new column in table A Like

AVERAGEX(FILTER(Table B, 'Table B'[timeIN] >= 'Table A'[start_date_time] && 'Table B'[timeIN] <= 'Table A'[End_date_time]),'Table B'[Info_Value])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Thanks that worked, and resolved my issue.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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 Solution Authors
Top Kudoed Authors