Forum Discussion

erhan_79's avatar
erhan_79
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

Lookup VAlue for repeating values

Hi there ;

 

i need your help for below issue ;

 

i have two table , Table A and Table as below , for both table i have order no , i would like to make lookup value for net price to Table B , but there will be rule like that ;

 

the net price which will  transfer to Table B , will be the net price of the last date's net price  always 

 

  • erhan_79 

    please try to create a column in table B

    NET PRICE = 
    VAR _MAXDATE = MAXX(FILTER('Table A','Table A'[order no]='Table B'[order no]),'Table A'[document date])
    RETURN MAXX(FILTER('Table A','Table A'[order no]='Table B'[order no] && 'Table A'[document date]=_MAXDATE),'Table A'[net price])

9 Replies

  • Here would be a simple measure that does that.

     

    Note that the totals are wrong. Is that important for you?

  • erhan_79 

    please try to create a column in table B

    NET PRICE = 
    VAR _MAXDATE = MAXX(FILTER('Table A','Table A'[order no]='Table B'[order no]),'Table A'[document date])
    RETURN MAXX(FILTER('Table A','Table A'[order no]='Table B'[order no] && 'Table A'[document date]=_MAXDATE),'Table A'[net price])

    • lbendlin's avatar
      lbendlin
      Icon for Super User rankSuper User

      Here is a version that also gets the Totals right.

       

       

  • visakhmurukes's avatar
    visakhmurukes
    Frequent Visitor
    SUMMARIZE(
    TableA,
    TableA[OrderNo],
    "LastPrice",LASTNONBLANKVALUE(TableA[DocumentDate],SUM(TableA[NetPrice]))
    )
    • lbendlin's avatar
      lbendlin
      Icon for Super User rankSuper User

      visakhmurukes  Interesting differences in the produced  queries

       

      versus

      Your version has many more row scans but still comes out better as it avoids the CallbackDataID issue in my version.

      • erhan_79's avatar
        erhan_79
        Icon for Post Prodigy rankPost Prodigy

        thanks for info lbendlin but this explaning so technical 🙂 i could not understand sorry , i am not responsible for IT 🙂 , so do you advice me anything else ?