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
kkandral
Regular Visitor

SAMELASTPERIOD BUG Continues similarly

I have just two tables Sales and Calendar

Sales

Date_of_S     Amount

10/1/2019         100$

4/2/2019            60$

5/2/2019            50$

28/2/2019        200$

10/1/2020          75$

1/2/2020            30$

3/2/2020            10$

4/2/2020            45$

5/2/2020            85$

 

calendar has been genarated with dates between two vars 

minD =calculate (min(dates_of_S),all(sales)) -- 10/1/2019

MaxD =calculate (max(dates_of_S),all(sales)) --  5/2/2020 

TotSales= sum(sales.amount)

TotalSalesLY= calculate(TotSales,sameperiodlastyear(calendar.date))  -- calendar is connected many to one with sales and has been declared as a dateTable on the model

* When I see Jan20 compared to Jan19 everything's perfect 

*When I see the sales of the period Feb2020 I receive TotSales 170$ (30+10+45+85)and TotSalesLY 310$ which is incorrect (this is the sum of Feb19 includes the sales of 28/2/2019) 

* When I use slicer and I select dates up to 4/2/2020 I receive correctly  TotSales 85$ (30+10+45) and TotSalesLY correctly 60$

* When I use multiple selection only 1/2/2020 and 5/2/2020 excluded the 4/2/2020 I receive 115$(30+85) and correctly for LY just 50$ (sales on 5/2/2019) 

* Crazy!! when I use multiple dates and I choose e.g 1/2 2/2 ___ ___  5/2 the result is correct

BUT when I use 1/2 __ __ 4/2 & 5/2 the last two dates of February returns the Total of February2019 310$ again ... (I give up)... The symptom meets the situation when you choose the 2 latest days of your sales?!?!?    

----

I should use eomonth functions to avoid that or hasnofilter IFs. 

Another aspect is when I use the sales date TotSalesLY= calculate(TotSales,sameperiodlastyear(sales.date_of_S)) the measure returns blank... 

I suspect there is a problem with the connection of my Calendar or something DAX systemic or my ignorance 

Thank you in advance

 ----

P.S SALES table derives from two tables appended in PowerQuery e.g Sales2019 into --> Sales

4 REPLIES 4
AlexAlberga727
Resolver II
Resolver II

I'd like to ask what the ultimate goal is here to best help.

 

Try this first however - 

 

TotSales = SUM (Sales.Amount)

 

AND

 

TotSales LY = CALCULATE ( [TotSales], DATEADD ( calendar.date , -1, YEAR )

The ultimate goal is to get the LastYear exactly of what I have in the CurrentYear

Has exactly the same reaction... Crazy? If I choose the first & last two dates of my date table returns 310$  

Can you share the values for the days you're trying to calculate? I'd like to play around with it a bit and provide a solution

 

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.