Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Create second Calendar table from an original Calendar table

Hi -

 

I a have calendar table with with two columns, Date [=Calendar(Date(2015, 1, 1), Date(2018, 12, 31)] and a Measure [= "Y" or "N"].

 

I want create a second calendar table that includes the Dates from the original where the measure equals "Y" (see tables below).

 

Thank you, Mark 

 

Original Table Second Table
DateMeasure Date
1/1/2015N  
1/2/2015N  
1/3/2015Y 1/3/2015
1/4/2015Y===>1/4/2015
:  :
12/30/2018Y 12/30/2018
12/31/2018N  

13 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    So, you should be able to do that like this:

     

    New Calendar = 
    VAR __table = ADDCOLUMNS(ALL('Date'),"__Measure",[Measure])
    RETURN
    FILTER(__table,[__Measure] = "Y")
    
    • Anonymous's avatar
      Anonymous
      Not applicable

      I will give that a try .  Thank you.  Just such a newbe to DAX, "simple" things take questions to learn.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Greg - The new calendar didn't seem to work, as it seemd to ignore the filter, and shows the entire range of the original calendar.

       

      Would you have any suggestions?

       

      The sample code was adjusted as shown below ... 

       

      NEW_CALENDAR = 
      VAR __table = ADDCOLUMNS(ALL('CALENDAR'[Date]),"__Measure",'CALENDAR'[Is In Date Range])
      RETURN
      FILTER('CALENDAR','CALENDAR'[Is In Date Range] = "Y")

      A picture of the original calendar and new calander is below.  I am wanting the New Calendar to show only 5/12/2018 to 5/20/2018

       

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Anonymous, not sure, I created it in my test environment and it seems to work. See attached Page 10. Calendar, New Calendar and Measure 4.