Forum Discussion

Diego-mx's avatar
Diego-mx
Advocate I
7 years ago
Solved

Switch between weekly and monthly Views

I have a Calendar table, which has at least three columns:  a_date, week_date, month_date; the last two corresponding to the beginning of the corresponding week and month.     So far, I've showed m...
  • v-yulgu-msft's avatar
    7 years ago

    Hi Diego-mx,

     



    Solution 2. 
    I create a secondary grouping calendar table with "long" format (as opposed to wide format), with columns "b_date" and "period" that looks like this: 

    b_date      period 
    7/1/2018   "month"
    8/1/2018   "month"
    9/1/2018   "month" 
    ... 
    7/1/2018   "week"
    7/8/2018   "week"
    7/15/2018  "week" 
    ....

    and this becomes easier to link but then I don't know how to create this table as a union of two tables with DAX syntax. 


    You can create a calculated table as below:

    CalendarTable2 =
    UNION (
        SELECTCOLUMNS (
            CalendarTable1,
            "b_date", CalendarTable1[week_date],
            "period", "Week"
        ),
        SELECTCOLUMNS (
            CalendarTable1,
            "b_date", CalendarTable1[month_date],
            "period", "Month"
        )
    )

    Best regards,

    Yuliana Gu