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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
htsvhwave
Helper II
Helper II

Help with creating index column

Currenly i am trying to make a index column to calculate absence periods for employees. With the current calculation the period end when there is a weekend or a public holiday, where as i need i to continue. when i period start where the alias is sick i need the index to be 1, after that the index should be zero until the period ends. If the alias isnt sick the index should be empty

htsvhwave_0-1689072138383.png

I have my date tabel

dateType of dayType of day nr
14/04/2022Public holiday3
15/04/2022Weekend2
16/04/2022Weekend2

I have to following tabels

InitialsdateAliasHoursindex(how is want the index to be)
xx10/04/2022sick81
xx11/04/2022sick80
xx12/04/2022sick80
xx13/04/2022sick80
xx17/04/2022sick80
xx18/04/2022sick80
xx19/04/2022work8 
xx20/04/2022sick81
3 REPLIES 3
Anonymous
Not applicable

Hi @htsvhwave ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create calculated columns.

Column = VAR CurrentDate = 'Table'[date]
VAR PreviousDate = CALCULATE(MAX('Table'[date]), FILTER('Table', 'Table'[date] < CurrentDate))
RETURN IF(WEEKDAY(CurrentDate, 2) > 1, PreviousDate, CALCULATE(MAX('Table'[date]), FILTER('Table', 'Table'[date] < CurrentDate - 1)))
Index = 
VAR PreviousAlias =CALCULATE(MAX('Table'[Alias]),FILTER('Table','Table'[date]=EARLIER('Table'[Column])))
RETURN
    IF (
        'Table'[Alias] = "sick",
        IF (
            PreviousAlias = "sick",
            0,
            1
        ),
        BLANK ()
    )

(3) Then the result is as follows.

vtangjiemsft_0-1689646533352.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Hi

i have updated the sample date with other scenrios. When a absence period start i need the index to be 1 and ather that 0. I have some employees that can have of days during the week and kan work during the public holiday and weekends somtimes so i hope the calculation also could considere this.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.