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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Two Tables with different date ranges (Weekly & Daily) to be merged into the same line graph

Hi All;,

 

I need to make a line graph with price on Y axis and weekly start dates(Monday) on the X axis. However I have two tables, one contains prices in a weekly format (see table below) and the other is prices in a daily format.

 

I have tried the USERELATIONSHIP DAX query to change the daily values(Table 2) into weekly values in Table 1

 

I know i have to create a relationship between the two tables to get this to work but I'm having trouble getting the correct start of week values without an error popping up.

 

Can anyone help?

stats_livestock_price.stat_weekstats_livestock_price.average_priceStart of week values Table 2
01/04/20194.562#ERROR
08/04/20194.723#ERROR
15/04/20194.682#ERROR
22/04/20194.658#ERROR
29/04/20194.621#ERROR
06/05/20194.547#ERROR
13/05/20194.613#ERROR
20/05/20194.982#ERROR
27/05/20194.79#ERROR
03/06/20194.725#ERROR
10/06/20194.515#ERROR
17/06/20194.516#ERROR
24/06/20194.497#ERROR
01/07/20194.335#ERROR
08/07/20194.149#ERROR
15/07/20194.146#ERROR
22/07/20193.995#ERROR
29/07/20193.955#ERROR
05/08/20193.952#ERROR
12/08/20193.944#ERROR
19/08/20193.92#ERROR
26/08/20193.919#ERROR
02/09/20193.866#ERROR
09/09/20193.789#ERROR
16/09/20193.742#ERROR
23/09/20193.723#ERROR
30/09/20193.712#ERROR
07/10/20193.713#ERROR
14/10/20193.743#ERROR
21/10/20193.735#ERROR
28/10/20193.771#ERROR
04/11/20193.9#ERROR
11/11/20194.073#ERROR
18/11/20194.215#ERROR
25/11/20194.233#ERROR
02/12/20194.274#ERROR
09/12/20194.317#ERROR
16/12/20194.298#ERROR
23/12/20194.38#ERROR
30/12/20194.501#ERROR
06/01/20204.503#ERROR
13/01/20204.547#ERROR
20/01/20204.634#ERROR
27/01/20204.71#ERROR
03/02/20204.966#ERROR
10/02/20205.228#ERROR
17/02/20205.32#ERROR
24/02/20205.303#ERROR
02/03/20205.309#ERROR
09/03/20205.397#ERROR
16/03/20205.514#ERROR
23/03/20205.166#ERROR
3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

https://community.powerbi.com/t5/Quick-Measures-Gallery/Week-Starting/m-p/391487#M123


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

I've followed your code and come up with:

 

mWeekStarting1 =
//Get information about the current date
VAR myDate = MAX(Sheet1[Intake_Data_Kill_Date])
VAR myWeekNum = WEEKNUM(myDate)
VAR myYear = YEAR(myDate)
//Set min and max for Calendar table
VAR minDate = CALCULATE(MIN(Sheet1[Intake_Data_Kill_Date]),ALL(Sheet1))
VAR maxDate = CALCULATE(MAX(Sheet1[Intake_Data_Kill_Date]),ALL(Sheet1))
//Create calendar table and add required columns
VAR dateTable = CALENDAR(minDate,maxDate)
VAR dateTable1 = ADDCOLUMNS(dateTable,"WeekNum",WEEKNUM([Date]))
VAR dateTable2 = ADDCOLUMNS(dateTable1,"WeekDay",WEEKDAY([Date]))
//Return date that matches the current year and weeknum and is a week day of 1 (Sunday)
VAR weekStartDate = MINX(FILTER(dateTable2,YEAR([Date])=myYear&&[WeekNum]=myWeekNum&&[WeekDay]=1),[Date])
//If null, then it is at the end of the year and the week starts last year - there may be 53 weeks that year
VAR weekStartDate1 = IF(NOT(ISBLANK(weekStartDate)),weekStartDate,MINX(FILTER(dateTable2,YEAR([Date])=myYear-1&&[WeekNum]=53&&[WeekDay]=1),[Date]))
//If null, then it is at the end of the year and the week starts last year - there may not be 53 weeks that year
VAR weekStartDate2 = IF(NOT(ISBLANK(weekStartDate1)),weekStartDate1,MINX(FILTER(dateTable2,YEAR([Date])=myYear-1&&[WeekNum]=52&&[WeekDay]=1),[Date]))
//If it is still null, then it is at the start of our calendar table
VAR weekStartDate3 = IF(NOT(ISBLANK(weekStartDate2)),weekStartDate2,MINX(dateTable2,[Date]))
//Return a nicely formatted week ending format "W# Week Ending mm/dd/yyyy"
RETURN "W" & myWeekNum & " Week Starting " & weekStartDate3
 
However this gives me 0 values along my graphTwo tables merge error.PNG
Anonymous
Not applicable

This is a job for Power Query, to be honest, not DAX. And please watch this:

https://www.youtube.com/watch?v=78d6mwR8GtA&t=1247s

https://www.youtube.com/watch?v=_quTwyvDfG0

Best
D

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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