Forum Discussion

George375's avatar
George375
Regular Visitor
3 years ago

Create a measure that only filters based on 2 fields

I have a table visual that has 7 columns from various different connected tables in PBI showing order history. I want to create a measure that shows the last time an item on a row was shipped to the customer at that same row but I want it to ignore the other columns in the visual as currently adding a max date measure only shows the date of that row and not the actual latest ship date. Any workarounds?

7 Replies

    • George375's avatar
      George375
      Regular Visitor

      Here is an example of what my situation is. Basically I have a log of historical data with order #, transaction date, item code and customer number. I want on each line a measure that shows the latest date that item went to that customer. But becuase the order # and date field are in the visual, the measure filters only on those dates when in the table so shows the undesired dates as seen on the example table. Want to know what dax would help me get a table like my goal and not what im currently getting

      Goal:

      Order NumberTransaction DateItem CodeCustomer NumberLatest Date
      11/1/2022ABC1231/4/2022
      21/2/2022ABC1231/4/2022
      31/3/2022ABC1231/4/2022
      41/4/2022ABC1231/4/2022

       

      What Im getting on PBI:

      Order NumberTransaction DateItem CodeCustomer NumberLatest Date
      11/1/2022ABC1231/1/2022
      21/2/2022ABC1231/2/2022
      31/3/2022ABC1231/3/2022
      41/4/2022ABC1231/4/2022
  • bolfri's avatar
    bolfri
    Icon for Solution Sage rankSolution Sage
    Last transaction date = 
    var this_order = 'Sample'[Order Number]
    var this_customer = 'Sample'[Customer Number]
    return CALCULATE(
        MAX('Sample'[Transaction Date]);
        'Sample'[Order Number] = this_order;
        'Sample'[Customer Number] = this_customer
    )

     

    Result:

    Is that what you meant?

    • George375's avatar
      George375
      Regular Visitor

      I need it to show 01.04.2022 for all as that was the last time it was shipped

      • bolfri's avatar
        bolfri
        Icon for Solution Sage rankSolution Sage

        Awww I am sorry, I didn't notice that. So you want a MAX(transaction date) for Customer Number?

         

        Max transaction date per customer = 
        var this_customer = [Customer Number]
        return CALCULATE(
            MAX([Transaction Date]);
            FILTER(Tabela;[Customer Number] = this_customer)
        )