Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Calculated Column on Analysis Services with Tabular Editor

Hello everyone and thanks in advance for anyone who can help me. The goal of this topic (for more details I have attached the example file), is to create a calculated column (WD Position Ranking) th...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hello @Fabio_RM86

    I build two tables to achieve your goal.

    Date table:

    Date = 
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2020, 01, 01 ), DATE ( 2020, 12, 31 ) ),
        "Year", YEAR ( [Date] ),
        "Month", MONTH ( [Date] ),
        "Day", DAY ( [Date] ),
        "Quarter", QUARTER ( [Date] ),
        "Week", WEEKNUM ( [Date], 1 ),
        "DayName", FORMAT ( [Date], "DDDD" ),
        "MonthName", FORMAT ( [Date], "MMMM" )
    )
    DayofYear = RANKX('Date','Date'[Date],,ASC)

    Holiday table:

    1.png

    Two related tables per date column and vacation column.

    Next, add an IsworkingDay column to DateTable.

    IsWorkingday = IF(RELATED(Holiday[HolidayName]) = BLANK(),IF(OR('Date'[DayName]="Saturday",'Date'[DayName]="Sunday"),0,1), 0)

    Finally build WD_Position_Ranking

    WD_Position_Ranking = 
    IF (
        'Date'[IsWorkingday] = 0,
        0,
        RANKX (
            FILTER (
                'Date',
                'Date'[Year] = EARLIER ( 'Date'[Year] )
                    && 'Date'[Month] = EARLIER ( 'Date'[Month] )
                    && 'Date'[IsWorkingday] <> 0
            ),
            'Date'[Date],
            ,
            ASC
        )
    )

    The result is as follows.

    2.png

    If you have other holidays, you can add it to the holiday table and get the new result.

    You can download the pbix file from this link: Calculated column in Analysis Services with Tabular Editor

    Best regards

    Rico Zhou

    If this post helps,then consider Accepting it as the solution to help other members find it faster.

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hello @Fabio_RM86

    Could you tell me if your problem has been solved? If so, here's the solution. More people will benefit from it. Or you are still confused about it, please provide more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

    Best regards

    Rico Zhou