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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
GSPBI
Frequent Visitor

Calculated Column - Show Last Week's Data in Current Week

Dear Microsoft PowerBI community,

 

I have been a long time user of this forum and I really appreciate all the users that raised their queries and the those that respond to them.


I have come across an issue that seems easy but I can't figure it out.


I have a table that looks like the below.

ABCD
IdPublication NumberActualPlanned
ExvfxB9PdcoRCuLKJalw371 
ExvfxB9PdcoRCuLKJalw36 1
fbHK1m9nAueKizAdKsWC371 
fbHK1m9nAueKizAdKsWC36 1
FuTeNOWeSSQ2tp4zhQ8V371 
FuTeNOWeSSQ2tp4zhQ8V36 1
G10bnm9UMTzoUtBeoyTl371 
G10bnm9UMTzoUtBeoyTl36 1


I want to create a calculated column F that moves last publication's planned figures (column D) in the current publication.



ABCDEF
IdPublication NumberActualPlannedNo. Activities AchievedNo. Activities Planned
ExvfxB9PdcoRCuLKJalw371 11
ExvfxB9PdcoRCuLKJalw36 1  
fbHK1m9nAueKizAdKsWC371 11
fbHK1m9nAueKizAdKsWC36 1  
FuTeNOWeSSQ2tp4zhQ8V371 11
FuTeNOWeSSQ2tp4zhQ8V36 1  
G10bnm9UMTzoUtBeoyTl371 11
G10bnm9UMTzoUtBeoyTl36 1  


What is the DAX calculated column that I need to produce? 

Any guidance would be appreciated.

 

Kind regards,

GSPBI

1 ACCEPTED SOLUTION
Russell-PBI
Resolver II
Resolver II

Hi @GSPBI, this seems to work:

No. Activities Planned = 
VAR PublicationNumber = 'Table'[Publication Number]
VAR PreviousPublicationNumber =
CALCULATE(
Max('Table'[Publication Number])
, ALLEXCEPT('Table','Table'[Id])
, ('Table'[Publication Number] < PublicationNumber)
)
RETURN
CALCULATE(
MAX('Table'[Planned])
, ALLEXCEPT('Table', 'Table'[Id])
, 'Table'[Publication Number] = PreviousPublicationNumber
)

View solution in original post

4 REPLIES 4
GSPBI
Frequent Visitor

Thank you very much @tamerj1 and @Russell-PBI for your responses. I appreciate your help! 👨‍🏫

v-eqin-msft
Community Support
Community Support

Hi @GSPBI ,

 

If the Publication Number is continuous and  there is only one row for each Id and each Publication Number, please try:

No. Activities Planned 1 = CALCULATE(MAX('Table'[Planned]),FILTER('Table',[Id]=EARLIER('Table'[Id]) && [Publication Number]=EARLIER('Table'[Publication Number])-1))

Or

No. Activities Planned 2 = LOOKUPVALUE('Table'[Planned],'Table'[Id],[Id],[Publication Number],[Publication Number]-1) 

Output:

Eyelyn9_0-1645582007229.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tamerj1
Super User
Super User

Hi @GSPBI 

many options. 
simplist is to to use LOOKUPVALUE and search for the same publication code but for publication number - 1

Russell-PBI
Resolver II
Resolver II

Hi @GSPBI, this seems to work:

No. Activities Planned = 
VAR PublicationNumber = 'Table'[Publication Number]
VAR PreviousPublicationNumber =
CALCULATE(
Max('Table'[Publication Number])
, ALLEXCEPT('Table','Table'[Id])
, ('Table'[Publication Number] < PublicationNumber)
)
RETURN
CALCULATE(
MAX('Table'[Planned])
, ALLEXCEPT('Table', 'Table'[Id])
, 'Table'[Publication Number] = PreviousPublicationNumber
)

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Kudoed Authors