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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors