This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
I have been tasked to create a measure that will show total revenue - 2 week revenue and another for total revenue and 4 weeks ago. I have these measures created already but the problem is they want these measures to popluate with a date slicer and I don't know how to do that can you help me.
Solved! Go to Solution.
Hi @Anonymous
Thank you very much sevenhills and Power2G for your prompt reply.
For your question, here is the method I provided:
Here's some dummy data
"Sales"
Ensure you have a Date table in your model.
DateTable = CALENDAR(MIN('Sales'[Date]), MAX('Sales'[Date]))
Create measures.
Revenue2WeeksAgo =
VAR DataWeekNUM = WEEKNUM(MAX('DateTable'[Date]))
RETURN
CALCULATE(
SUM('Sales'[Revenue]),
FILTER(
ALL('Sales'),
WEEKNUM('Sales'[Date]) < DataWeekNUM
&&
WEEKNUM('Sales'[Date]) >= DataWeekNUM - 2
)
)
Revenue4WeeksAgo =
VAR DataWeekNUM = WEEKNUM(MAX('DateTable'[Date]))
RETURN
CALCULATE(
SUM('Sales'[Revenue]),
FILTER(
ALL('Sales'),
WEEKNUM('Sales'[Date]) < DataWeekNUM
&&
WEEKNUM('Sales'[Date]) >= DataWeekNUM - 4
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Thank you very much sevenhills and Power2G for your prompt reply.
For your question, here is the method I provided:
Here's some dummy data
"Sales"
Ensure you have a Date table in your model.
DateTable = CALENDAR(MIN('Sales'[Date]), MAX('Sales'[Date]))
Create measures.
Revenue2WeeksAgo =
VAR DataWeekNUM = WEEKNUM(MAX('DateTable'[Date]))
RETURN
CALCULATE(
SUM('Sales'[Revenue]),
FILTER(
ALL('Sales'),
WEEKNUM('Sales'[Date]) < DataWeekNUM
&&
WEEKNUM('Sales'[Date]) >= DataWeekNUM - 2
)
)
Revenue4WeeksAgo =
VAR DataWeekNUM = WEEKNUM(MAX('DateTable'[Date]))
RETURN
CALCULATE(
SUM('Sales'[Revenue]),
FILTER(
ALL('Sales'),
WEEKNUM('Sales'[Date]) < DataWeekNUM
&&
WEEKNUM('Sales'[Date]) >= DataWeekNUM - 4
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I think your post title says Calculated Column and you are asking for measures! This is minor point.
Let us go through your requirements
1. You already have [Total Revenue], [Total Revenue - 2 W], [Total Revenue - 4 W] measures
2. You want to adjust based on a date slicer.
You can do these:
1. Create a slicer using your date table
2. Adjust the measures, let u do one and then you can do the other similar way by adjusting -14 as -28.
[Total Revenue - 2 W] =
VAR _SelDate =
IF (
ISFILTERED ( 'DateTable'[Date] ),
MAX( 'DateTable'[Date] ),
BLANK()
)
RETURN IF( ISBLANK( SUM(Sales[Revenue]) ) || ISBLANK( _SelDate ) || NOT HASONEVALUE('DateTable'[Date]), BLANK(),
CALCULATE (
SUM ( 'Sales'[Revenue] ),
DATESINPERIOD( Sales[Date], _SelDate, -14, DAY )
)
)
3. For testing add 2 dummy measures and remove after your testing
Total Revenue - 2 W - Min Date =
VAR _SelDate =
IF (
ISFILTERED ( 'DateTable'[Date] ),
MAX( 'DateTable'[Date] ),
BLANK()
)
RETURN minx( DATESINPERIOD( 'DateTable'[Date], _SelDate, -14, DAY ) , 'DateTable'[Date])
Total Revenue - 2 W - Max Date =
VAR _SelDate =
IF (
ISFILTERED ( 'DateTable'[Date] ),
MAX( 'DateTable'[Date] ),
BLANK()
)
RETURN maxx( DATESINPERIOD( 'DateTable'[Date], _SelDate, -14, DAY ) , 'DateTable'[Date])
Sample from adventure works:
Hope it helps!
To beging, make sure you have a proper date table in your data model and create relationships between your Sales[Date] and the Date table.
First measure
TotalRevenue = SUM(Sales[Revenue])Second measure
RevenueLast2Weeks =
CALCULATE(
[TotalRevenue],
DATESINPERIOD(
Sales[Date],
MAX(Sales[Date]),
-2,
WEEK
)
)Third measure
RevenueLast4Weeks =
CALCULATE(
[TotalRevenue],
DATESINPERIOD(
Sales[Date],
MAX(Sales[Date]),
-4,
WEEK
)
)
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 25 | |
| 23 | |
| 22 | |
| 17 | |
| 14 |
| User | Count |
|---|---|
| 25 | |
| 24 | |
| 20 | |
| 19 | |
| 19 |