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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply

Calculated column using 'lookup' in same table

I'm trying to compute a caluculated column in the Calendar to show which period is current, past of future. Can't get my head around it how to do this. 

The difficulty is that I need my calendar to be of week and period granularity, not on date level. I do have a Week Start Date. 

Periods are sections of weeks. Sometimes 4 weeks, sometimes 5. Not much logic there. 

 

We are now in Period 7, and I did manage to write a DAX that tells me that this week, we are in the current period. See screenshot below. 

Next I need to do some sort of lookup.

  • If Period =7, then lookup and find the string "This Period".
  • If Period >7, then Future.
  • If Periode <7, then Passed.  

Your help is much appreciated!

 

Stevenconance_0-1658401593899.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Steven-conance ,

 

According to your screenshot, I think we can determind [Period] based on [Week Start Date]. My code is based on this logic, we will calculate week start date based on today and then get period. Then use this dynamic period in switch.

Please try it to create a calculated column.

Passed/Current/Future Periods =
VAR _WeekStart_Date =
    TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
VAR _Period =
    CALCULATE (
        SUM ( 'TableName'[Period] ),
        FILTER ( 'TableName', 'TableName'[Week Date Start] = _WeekStart_Date )
    )
RETURN
    SWITCH (
        TRUE (),
        [Period] > _Period, "Future",
        [Period] = _Period, "This Period",
        [Period] < _Period, "Past"
    )

 

Best Regards,
Rico Zhou

 

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

8 REPLIES 8

@Anonymous not actually it's a 445 rythm. First period is 4 weeks, second period is 4 week, third period is 5 weeks. 

And then x4 for a full year

Anonymous
Not applicable

Hi @Steven-conance ,

 

According to your screenshot, I think we can determind [Period] based on [Week Start Date]. My code is based on this logic, we will calculate week start date based on today and then get period. Then use this dynamic period in switch.

Please try it to create a calculated column.

Passed/Current/Future Periods =
VAR _WeekStart_Date =
    TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
VAR _Period =
    CALCULATE (
        SUM ( 'TableName'[Period] ),
        FILTER ( 'TableName', 'TableName'[Week Date Start] = _WeekStart_Date )
    )
RETURN
    SWITCH (
        TRUE (),
        [Period] > _Period, "Future",
        [Period] = _Period, "This Period",
        [Period] < _Period, "Past"
    )

 

Best Regards,
Rico Zhou

 

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

Thanks @Anonymous, works like a charm. Today a new period started, and it switched exactly as intended. Thanks! 

In essence, yes. But how to make this dynamic? When we're in Period 8, it's supposed to change. Then Period 8 is the current period. And so on

 

@Steven-conance , try like

New column =

var _max  = maxx(filter(Table, Table[Date] = Today())  , [Week] )

return

Switch( True() ,

_max  >7 , "Future",

_max  = 7 , "This Period",

_max  < 7 , "Past")

 

Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak but again the question remains. The "7" here will be a different number every 4 weeks, so how to make that dynamic?

 

 

Anonymous
Not applicable

Hi @Steven-conance ,

 

Do you mean that period will increase every 4 weeks? Current period equal to 7 and after 4 weeks period equal to 8?

You can try this code to create a calculate column. We can get Period dynamiclly.

Passed/Current/Future Periods =
VAR _WeekStart_Date =
    TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
VAR _Period =
    CALCULATE (
        SUM ( 'TableName'[Period] ),
        FILTER ( 'TableName', 'TableName'[Week Date Start] = _WeekStart_Date )
    )
RETURN
    SWITCH (
        TRUE (),
        [Period] > _Period, "Future",
        [Period] = _Period, "This Period",
        [Period] < _Period, "Past"
    )

 

Best Regards,
Rico Zhou

 

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

amitchandak
Super User
Super User

@Steven-conance , to me=e it seems like that does not need lookup. a new column

 

Switch( True() ,

[Week] >7 , "Future",

[Week] = 7 , "This Period",

[Week] < 7 , "Past")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

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.