Forum Discussion

GR_Oxnard_STU's avatar
GR_Oxnard_STU
Regular Visitor
5 years ago
Solved

Create virtual table using Max and Min dates from date prompt

Please help.  I am trying to create a virtual table using the Max and Min dates from the Date prompt.  The Date prompt uses the date from a Calendar table that is not linked to the source table (say ...
  • v-luwang-msft's avatar
    5 years ago

    Hi  GR_Oxnard_STU ,

    Pls see the below:

    base table:

    CALENDAR_DTE = CALENDAR("2021/1/1","2021/6/1")

     

    Relationship:

     

    Then use the following measure to create a new table:

    Tbl_OPEN_ORDERS =
    VAR MAXDTE =
        MAX ( CALENDAR_DTE[Date] )
    VAR MINDTE =
        MIN ( CALENDAR_DTE[Date] )
    RETURN
        CALCULATETABLE (
            SUMMARIZE (
                'Table',
                'Table'[ordernumber],
                'Table'[open date],
                'Table'[close date]
            ),
            'Table'[open date] <= MAXDTE
                && 'Table'[close date] >= MINDTE
        )

    Final get the below:

     

    You could adjust the differnet between your dax with my dax.

    And about error The expression contains multiple columns, but only a single column can be used in a true/false expression that is used as a table filter expression

    the following articles tells:If you need to invoke CALCULATE using more than one column in the condition, you need to use FILTER function, which provides a list of values instead of a condition. Since these two tables are related by the "Matter Number" field, you can use RELATED() function to compare two column values.

     

     

    Wish it is helpful for you!

     

     

    Best Regards

    Lucien