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
rcb0325
Helper I
Helper I

Issue with connecting an external source with previous year's info!

I am trying to calculate previous year's sales from an external source, and show it as a 'last year to date' calculation. 

 

The main dataset holds this years sales info, and I have a [Sales Amount YTD] calculation that is working correctly. I am having a hard time summing the sales amount in the external data source (excel file), and showing that total as [Sales Amount LYTD]. The value shown as the LYTD in the table is the total for all of 2023, and not just 01/01/2023-01/23/2023. 

 

I cannot create a hard relationship inside of the data model because of other current relationships, so I have been trying to use TREATAS. 

 

Below are a couple of pictures. One is just the current table, showing the incorrect LYTD total, and the other is of the data tables. 'PostingDate' is the main dataset, and 'Mfg Rep Sales' is the external excel file housing 2023 info.  

 

dataset.pngsales_ytd.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rcb0325 ,

Can you provide the DAX you used for your calculations?
Without data and DAX, for the problem you are facing, I can only suggest you to use this filter condition in DAX when calculating the sum of the corresponding time period last year:

YEAR('DATE'[Date]) = YEAR(SELECTEDVALUE('DATE'[Date]) - 1 && MONTH('DATE'[Date]) = MONTH(SELECTEDVALUE('DATE'[Date]) && DAY('DATE'[Date]) = DAY(SELECTEDVALUE('DATE'[Date])


Best Regards,
Dino Tao
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
rcb0325
Helper I
Helper I

@Anonymous , I misread your formula. It appears to be working this way! 

 

Sales_Amount_LYTD =
CALCULATE( SUM( 'Mfg Rep Sales'[Invoiced Amount]),
YEAR('Mfg Rep Sales'[Invoice Date]) = YEAR(SELECTEDVALUE('dim PostingDate'[PostingDateDate])) -1 && MONTH('Mfg Rep Sales'[Invoice Date]) = MONTH(SELECTEDVALUE('dim PostingDate'[PostingDateDate])) && DAY('Mfg Rep Sales'[Invoice Date]) = DAY(SELECTEDVALUE('dim PostingDate'[PostingDateDate]))
)
 
Thank you for your help. 
rcb0325
Helper I
Helper I

@Anonymous here is the calculation for the current [Sales_Amount LYTD] 

 

Sales_Amount LYTD =
CALCULATE( SUM( 'Mfg Rep Sales'[Invoiced Amount]),
PARALLELPERIOD( 'dim PostingDate'[PostingDateDate], -1, YEAR),
TREATAS( VALUES('Mfg Rep Sales'[Invoice Date]), 'dim PostingDate'[PostingDateDate])
)
 
I cannot provide the calculation for the [Sales Amount YTD] column, because of data security reasons. 
 
In your calculation, I cannot insert the 'Invoice Date' column from the 'Mfg Rep Sales' table, as if it isnt allowed. Tyring to mark the column as a date table, I get an error of 'column must have unique values' and 'column cant have gaps'. Any suggestions? 
Anonymous
Not applicable

Hi @rcb0325 ,

Can you provide the DAX you used for your calculations?
Without data and DAX, for the problem you are facing, I can only suggest you to use this filter condition in DAX when calculating the sum of the corresponding time period last year:

YEAR('DATE'[Date]) = YEAR(SELECTEDVALUE('DATE'[Date]) - 1 && MONTH('DATE'[Date]) = MONTH(SELECTEDVALUE('DATE'[Date]) && DAY('DATE'[Date]) = DAY(SELECTEDVALUE('DATE'[Date])


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

@Anonymous are you able to help me be able to sum the LYTD totals by company? Since the [Posting Date] values are not in this particular table, the measure will not work properly. It will work if I remove the [Company] column, and add in [Posting Date].

 

Sales_Amount_LYTD =
CALCULATESUM'Mfg Rep Sales'[Invoiced Amount]),
YEAR('Mfg Rep Sales'[Invoice Date]) = YEAR(SELECTEDVALUE('dim PostingDate'[PostingDateDate])) -1 && MONTH('Mfg Rep Sales'[Invoice Date]) = MONTH(SELECTEDVALUE('dim PostingDate'[PostingDateDate])) && DAY('Mfg Rep Sales'[Invoice Date]) = DAY(SELECTEDVALUE('dim PostingDate'[PostingDateDate]))
)
 
Screenshot 2024-01-26 120756.png

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!

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.