cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
edsonlf
Frequent Visitor

Week over Week change for the same document

Hello guys!

 

I have a table called "OPEN POs" that looks like this:

 

WeekNumSupplierPO numberPayment term
33A15830 days
33C10560 days
33Y46930 days
33A42290 days
33Y78975 days
33U156120 days
33Y11145 days
34A15860 days
34C10560 days
34T8890 days
34Z156120 days
34U777120 days
34B87945 days
34Y78945 days
34U156120 days

 

I'm trying to build a matrix like this:

 

Week 34PO numberSupplierFromTo
 158A30 days60 days
 789Y75 days45 days

 

The idea is to show the "PO numbers" that had its "Payment term" changed from one week to another.

The variation always needs to be from the current week (that will be selected on the slicer) versus the previous week.

 

Can you guys please help me on this one?

 

@mahoneypat ideas? 😁 😬

 

Thank you for the support! 🙂

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

What should happen in week number 1 ?

 

Anyway.  Add two calculated columns  (measures are not required here as there is no filter impact)

 

Last Week = 
var p='OPEN POs'[PO number]
var s='OPEN POs'[Supplier]
var w='OPEN POs'[WeekNum]
return calculate(max('OPEN POs'[Payment term]),all('OPEN POs'),'OPEN POs'[PO number]=p,'OPEN POs'[Supplier]=s,'OPEN POs'[WeekNum]=w-1)

Different = SWITCH(TRUE(),ISBLANK('OPEN POs'[Last Week]),"no",[Last Week]='OPEN POs'[Payment term],"no","yes")

 

Then filter your table to Different="yes"

 

lbendlin_0-1597964797261.png

 

 

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@edsonlf , refer my blog on Week over a week using week rank. But for that, you need a week and year. In case you only have a week. You can use week in place of week rank.

Power BI — WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!
mahoneypat
Super User
Super User

Please try these two expressions for From and To.  They seem to get your desired result.

 

From = var prevweek = Max(Terms[WeekNum])-1
return CALCULATE(MIN(Terms[Payment term]), Terms[WeekNum] = prevweek)
 
To = var latestweek = Max(Terms[WeekNum])
return CALCULATE(MIN(Terms[Payment term]), Terms[WeekNum] = latestweek)
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


lbendlin
Super User
Super User

What should happen in week number 1 ?

 

Anyway.  Add two calculated columns  (measures are not required here as there is no filter impact)

 

Last Week = 
var p='OPEN POs'[PO number]
var s='OPEN POs'[Supplier]
var w='OPEN POs'[WeekNum]
return calculate(max('OPEN POs'[Payment term]),all('OPEN POs'),'OPEN POs'[PO number]=p,'OPEN POs'[Supplier]=s,'OPEN POs'[WeekNum]=w-1)

Different = SWITCH(TRUE(),ISBLANK('OPEN POs'[Last Week]),"no",[Last Week]='OPEN POs'[Payment term],"no","yes")

 

Then filter your table to Different="yes"

 

lbendlin_0-1597964797261.png

 

 

edsonlf
Frequent Visitor

Let me try this solution..

btw, week number one can be null.. no reference to bring any variance. 

that's not what I meant.  Is your report limited to a single year?  Or would you expect week 1 look back at week 52 of the prior year etc?

edsonlf
Frequent Visitor

good catch.. at some point i'll have the same week for a subsequent year

Greg_Deckler
Super User
Super User

@edsonlf - You should be able to borrow the concept from MTBF. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May 23 2022 episode 5 with aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt will talk about the importance of Data Modeling.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!