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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
OldN00b
Frequent Visitor

Week over Week difference with slicer to change the "current date"

I am trying to calculate the 1 week change in an index level (Yield Bps) based on a selected date within a slicer.

 

In my data, "Date" in Data table represents the current date in the slicer, calendar DatePreviousWeek in date table represents the 1 week from selected date. How can i show the change from these two fields for Yield (bps)?

 

Below is an example of my data. The Field "Calendar DatePreviousWeek" comes from the Date table. The rest of the fields are within the data table. The data and date table share a one to one relationship with each other.

 

Slicer = Date Field in Data Table

calculation is simply (Yield where date = selected date in slicer) - (yield where date = Calendar DatePreviousWeek)

 

Index IdentifierDATECalendar DatePreviousWeekYield (Bps)
BAMLC0A0CM1/3/2022 0:0012/27/2021 0:0097
BAMLC0A0CM1/4/2022 0:0012/28/2021 0:0096
BAMLC0A0CM1/5/2022 0:0012/29/2021 0:0095
BAMLC0A0CM1/6/2022 0:0012/30/2021 0:0095
BAMLC0A0CM1/7/2022 0:0012/31/2021 0:0095
BAMLC0A0CM1/10/2022 0:001/3/2022 0:0096
BAMLC0A0CM1/11/2022 0:001/4/2022 0:0096
BAMLC0A0CM1/12/2022 0:001/5/2022 0:0096
BAMLC0A0CM1/13/2022 0:001/6/2022 0:0097
BAMLC0A0CM1/14/2022 0:001/7/2022 0:0097
BAMLC0A0CM1/17/2022 0:001/10/2022 0:0097
BAMLC0A0CM1/18/2022 0:001/11/2022 0:0098
BAMLC0A0CM1/19/2022 0:001/12/2022 0:0099
BAMLC0A0CM1/20/2022 0:001/13/2022 0:00100
BAMLC0A0CM1/21/2022 0:001/14/2022 0:00103
BAMLC0A0CM1/24/2022 0:001/17/2022 0:00105
BAMLC0A0CM1/25/2022 0:001/18/2022 0:00105
BAMLC0A0CM1/26/2022 0:001/19/2022 0:00103
BAMLC0A0CM1/27/2022 0:001/20/2022 0:00107
BAMLC0A0CM1/28/2022 0:001/21/2022 0:00109
BAMLC0A0CM1/31/2022 0:001/24/2022 0:00110
BAMLC0A0CM2/1/2022 0:001/25/2022 0:00108

 

3 REPLIES 3
DimaMD
Solution Sage
Solution Sage

@OldN00b Hi, Can you provide your expected result?


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

 

Current_Bps is a measure that represents the Yield (Bps) column for a selected date in a slicer (in this case 12/14/2022).  1_week_ago_bps is a measure that represents the Yield (Bps) column using the 1_week_ago_date measure as a filtering criteria. 

 

My expected results are difference between current_bps-1_week_ago_bps measures. The issue is that the 1_week_ago_bps measure is returning null and i don't know why / how to fix it.

 

 

Below are the formulas to calculate each measure:

Bps Chg. 1Week =

 

var num = CALCULATE(max('FRED Data'[Yield (Bps)]),FILTER(all('FRED Data'[Date]),'FRED Data'[Date] = [current_date]))

 

var den = CALCULATE(max('FRED Data'[Yield (Bps)]),FILTER('FRED Data','FRED Data'[Date] = [1_week_ago_date]))

 

var calc = num - den return calc

 

image.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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