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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Calculated Column

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.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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"

vnuocmsft_0-1738737355301.png

 

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.

 

vnuocmsft_1-1738737642100.png

 

Regards,

Nono Chen

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

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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"

vnuocmsft_0-1738737355301.png

 

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.

 

vnuocmsft_1-1738737642100.png

 

Regards,

Nono Chen

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

 

 

sevenhills
Super User
Super User

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 

sevenhills_0-1738778298788.png

 

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:

sevenhills_1-1738778501694.png

 

 

 Hope it helps!

Power2G
Frequent Visitor

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
    )
)

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.