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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
aysultaniya
Frequent Visitor

SAME PERIOD LAST YEAR

 It is urgent please help

 

I have data till 1st Aug 2023 in an Excel sheet. The remaining sheet is blank below the 1st AUg.

Slicer Selection:-
31st July 2023 to 1st August 2023

Date SUM Last Year

----- ------ --------

31/7/2022 8
1/08/2022 9

...

31/7/2023 7 8
1/8/2023 3 9

Required output Current_year 10 and last_year 17

But the output of last year is not 17 (more than this) because It is sum of the whole August not only the selected dates.

The remaining dates it is working well only the last date of the data is showing this error.

DAX Query Last_year = CALCULATE([Measure_sum],SAMEPERIODLASTYEAR([date]))
Also Used CALCULATE([Measure_sum],dateadd([date], -1, year))

Both have the same output.

1 ACCEPTED SOLUTION

Hi @mickey64 one of best practice to create Date table is on link 

https://dax.guide/calendarauto/ 

Limiting dates as in your Step 1 could result in wrong calculation of previous years data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

5 REPLIES 5
some_bih
Super User
Super User

Hi @aysultaniya please check link below:

https://www.daxpatterns.com/standard-time-related-calculations/ 

Focus on part Controlling the visualization in future dates as I understand this could be your part of issue.

After that find your scenario (measure). It could be "Sales PY"  from picture below as you want fair comparision with previous year

Did I answer your question? Mark my post as a solution! Kudos Appreciated!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






mickey64
Super User
Super User

I think it may be a bug of Power BI.

 

Step 1: I made a calendar table. [Till 2023/8/2 or Later]

mickey64_0-1692167368390.png

 

Step 2: I made a relationship.

mickey64_1-1692167399961.png

 

Step 3: I made some visuals.

mickey64_2-1692167438545.png

 

Hi @mickey64 one of best practice to create Date table is on link 

https://dax.guide/calendarauto/ 

Limiting dates as in your Step 1 could result in wrong calculation of previous years data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Thank you for your suggestion but I am not able to solve the problem with this . Please provide another solution for that.

some_bih
Super User
Super User

Hi @aysultaniya please check link below:

https://www.daxpatterns.com/standard-time-related-calculations/ 

Focus on part Controlling the visualization in future dates as I understand this could be your part of issue.

After that find your scenario (measure). It could be "Sales PY"  from picture below as you want fair comparision with previous year

Did I answer your question? Mark my post as a solution! Kudos Appreciated!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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