Forum Discussion

dragon_prince's avatar
dragon_prince
Frequent Visitor
3 years ago

Lookup the Quarter value from another table

I have two tables, Snapshot Table and Close Date table. I want to pull the Snapshot data, its arr and then for the same quarter, all the matching values of arr in close date table. 
Please help me in this!

Input      
Snapshot_dateAccount_idArr Close_DateAccount_idArr
Mar-201210 Mar-20128
Mar-20342 Apr-20345
May-20157 May-20153
May-20169 Jun-20162
Aug-20117 Aug-20111
Aug-20107 Sep-201013
Nov-20147 Nov-20147
Nov-20137 Nov-201344
       
Output      
Monthsnapshot_arrclosed_arr    
Mar-20128    
May-20163    
Aug-20141    
Nov-201451    

3 Replies

  • hi dragon_prince 

    you may create a calculated table like this:

    Table = 
    VAR _table1 =
    SELECTCOLUMNS(
        INTERSECT(VALUES(Close_Date[Close_Date]), VALUES(Snapshot[Snapshot_date])),
        "Date", Close_Date[Close_Date]
    )
    RETURN
    ADDCOLUMNS(
        SUMMARIZE(_table1, [Date]),
        "snapshot_arr",
        VAR _date = [Date]
        RETURN
        SUMX(
            FILTER(
                ALL(Snapshot),
                Snapshot[Snapshot_date] = _date
            ),
            Snapshot[Arr]
        ),
        "closedate_arr",
        VAR _date = [Date]
        RETURN
        SUMX(
            FILTER(
                ALL(Close_Date),
               Close_Date[Close_date] = _date
            ),
           Close_Date[Arr]
        )
    )

     

    verified with your sample data and worked like this:

  • Hi,

    How you arrived at the numbers in the snapshot_arr column of the output table?  Give a proper explanation.