Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I have a table that looks somehow like this:
Date | Portfolio Size | P/L |
08/01/2021 | $100,000 | $100 |
11/01/2021 | $100,100 | $200 |
12/01/2021 | $100,300 | $300 |
13/01/2021 | $100,600 | $200 |
08/01/2021 is the last working day of the last week.
I would like to create a measure that will calculate the sum of P/L for the current week and divide by the last "Portfolio Size" value from last week.
Thank you.
@ashrafkotb , first if all you need to create a Saturday to Friday Week (Based on date you Said)
Refer my blog for this - Any Weekday Week - Start From Any day of Week
https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...
Now you have to create a Rank on the Week start date or Week Number and use that, refer to my blog for that
Power BI — Week on Week and 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...
https://www.youtube.com/watch?v=pnAesWxYgJ8
The column you need in the date table
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
or
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYMM format
Measures you need
This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Thank you, Amit. The week calculations were very helpful.
I created all the week columns and they make sense. I'm still not clear about the measure.
The measure I'm looking for should sum the (P/L) column and divide it by the last value of the (Portfolio Size) column from the previous week.
Appreciate if you could help with the correct measure calculation.
Thank you
Using this measure:
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
6 |