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

Sameperiodalstyear calculation for last years same week of month

I have an issue that my measure for Sameperiodalstyear is not filtered to get sales of last year the same week of month period ist only calculate the month period but i was filtered to show the week of the month and it does not work.

Anyone can help me to right the measure for Sameperiodalstyear that calculates the week of the month period, not the whole month.
my report is sent every end of the week to my reporter so the measure should show the week period of the month, not the whole month. 

 

i have a date table and there are relationships with the salse table, and the date table i have calculated column the defines the dates similar to current week and i use this to filter to filter per week. 

 

2022-02-05_14-23-15.jpg

4 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@xcrmadmin You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Whitewater100
Solution Sage
Solution Sage

This measure may solve your problem. I am using [Total Sales] for the measure to get to any time frame that is filtered for, for prior year.

 

Sales LY = CALCULATE( [Total Sales], DATEADD( Dates[Date], -1, YEAR ) )
 
Sales LY-1 = CALCULATE( [Total Sales], DATEADD( Dates[Date], -2, YEAR ) )

View solution in original post

hello 
thank you so much the refrences that you shared help me to catch this function 

 PREVIOUSYEAR ( 'Date'[Date] )

and my final code that solve may issue is compination between @Whitewater100 and @Greg_Deckler 

 CALCULATE ( SUM ( DIM_WON_ANALYTICS[actualvalue] ), //SAMEPERIODLASTYEAR ( 'Date'[Date] ), //DATEADD ( 'Date'[Date] , - 1 , YEAR ) PREVIOUSYEAR ( 'Date'[Date] ), 'Date'[IsWeek] = "Current Week", 'Date'[IsMonth] = "Yes" ) RETURN IF ( RST > 0, RST, 0 )

 

View solution in original post

hello 
thank you so much the refrences that you shared help me to catch this function 

 PREVIOUSYEAR ( 'Date'[Date] )

and my final code that solve may issue is compination between @Whitewater100 and @Greg_Deckler 

 CALCULATE ( SUM ( DIM_WON_ANALYTICS[actualvalue] ), //SAMEPERIODLASTYEAR ( 'Date'[Date] ), //DATEADD ( 'Date'[Date] , - 1 , YEAR ) PREVIOUSYEAR ( 'Date'[Date] ), 'Date'[IsWeek] = "Current Week", 'Date'[IsMonth] = "Yes" ) RETURN IF ( RST > 0, RST, 0 )

 

View solution in original post

5 REPLIES 5
Whitewater100
Solution Sage
Solution Sage

This measure may solve your problem. I am using [Total Sales] for the measure to get to any time frame that is filtered for, for prior year.

 

Sales LY = CALCULATE( [Total Sales], DATEADD( Dates[Date], -1, YEAR ) )
 
Sales LY-1 = CALCULATE( [Total Sales], DATEADD( Dates[Date], -2, YEAR ) )

Hi 

thank you for your solution, but when i appy your idea the result coming fine but there are zero value instead of the actual value that should appear of previues year for 2021 (AALY) the value appear zero and its should appear 37750

 

i dont know what the wrong. 

 

zero issue.jpg

hello 
thank you so much the refrences that you shared help me to catch this function 

 PREVIOUSYEAR ( 'Date'[Date] )

and my final code that solve may issue is compination between @Whitewater100 and @Greg_Deckler 

 CALCULATE ( SUM ( DIM_WON_ANALYTICS[actualvalue] ), //SAMEPERIODLASTYEAR ( 'Date'[Date] ), //DATEADD ( 'Date'[Date] , - 1 , YEAR ) PREVIOUSYEAR ( 'Date'[Date] ), 'Date'[IsWeek] = "Current Week", 'Date'[IsMonth] = "Yes" ) RETURN IF ( RST > 0, RST, 0 )

 

Greg_Deckler
Super User
Super User

@xcrmadmin You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

hello 
thank you so much the refrences that you shared help me to catch this function 

 PREVIOUSYEAR ( 'Date'[Date] )

and my final code that solve may issue is compination between @Whitewater100 and @Greg_Deckler 

 CALCULATE ( SUM ( DIM_WON_ANALYTICS[actualvalue] ), //SAMEPERIODLASTYEAR ( 'Date'[Date] ), //DATEADD ( 'Date'[Date] , - 1 , YEAR ) PREVIOUSYEAR ( 'Date'[Date] ), 'Date'[IsWeek] = "Current Week", 'Date'[IsMonth] = "Yes" ) RETURN IF ( RST > 0, RST, 0 )

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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