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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Valentb
Advocate I
Advocate I

Compare same campaign - Different dates in Previous Year Using DAX

Hi Guys,

 

I'm trying to solve a puzzle.

I have a date_dim that contain dates and campaign name.
Since the campaigns both can have variable dates but needs to be the same 'campaign name -1 year'


I cannot use sameperiod last year, but maybe date add and some variable?
I'm just really stuck and have no clue how to solve this.

Thanks alot for any help


Campaign_diff_dates.PNG

1 ACCEPTED SOLUTION
Valentb
Advocate I
Advocate I

Edited: Got it working. added Convert ((...), String)

So far have the following code, but it's not working when i insert -1 it no longer works.
Tried adding "Value" - doesn't help




I'm close - also it's direct query in dual mode so no calculated column is allowed

 

Var last_campaign = (LEFT(SELECTEDVALUE(Date[Campagin_Name]),3)&" "& Value(RIGHT(SELECTEDVALUE(Date[Campagin_Name]),4)-1))

return

CALCULATE([Sales],
REMOVEFILTERS(Date),
Filter(Date,Values(Date[Campagin_Name])=last_campaign))

 

 

View solution in original post

3 REPLIES 3
Valentb
Advocate I
Advocate I

Edited: Got it working. added Convert ((...), String)

So far have the following code, but it's not working when i insert -1 it no longer works.
Tried adding "Value" - doesn't help




I'm close - also it's direct query in dual mode so no calculated column is allowed

 

Var last_campaign = (LEFT(SELECTEDVALUE(Date[Campagin_Name]),3)&" "& Value(RIGHT(SELECTEDVALUE(Date[Campagin_Name]),4)-1))

return

CALCULATE([Sales],
REMOVEFILTERS(Date),
Filter(Date,Values(Date[Campagin_Name])=last_campaign))

 

 

mickey64
Super User
Super User

For your reference.

 

I added 'Campaign_Name-1' column in the table.

You can select 2 campaigns with 2 slicers.

 

mickey64_0-1694883242838.png

 

VijayP
Super User
Super User

@Valentb 

Try using DateADD, just attempt and if you have challenge paste the current result with expected result




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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