Forum Discussion

Russ99's avatar
Russ99
Helper I
4 years ago
Solved

dax formula

Hi Community,

 

I need some help writing a formula that will calculate when a customer is meant to pay for an item. The date they are meant to pay depends on 2 things, how many days their payment terms are and whether these terms are net or end of month. I have one column called "net or eom" and one called "payment terms"

 

The formula I have drafted on paper, that doesnt work in power BI is as below. 

 

date customer meant to pay = if([net or eom]="net",[transaction date] + [payment terms]),(EOMONTH([transaction date],0)+[payment terms]

 

ideally my output should be in the format dd/mm/yyyy.

 

I think the reason it is not working is becuase i dont have explicit measures, i am not sure what arguments i need to change to explicit measures and how to do so

i think it also worth mentioning that currently these are all colums and none are measure. also colum [transaction date] is in one table and [payment terms] and [net or eom] sit in a different table. the tables are related by customer name.

 

thanks for all of your help!!

 

Russ 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Russ99 ,

     

    My sample is as below.

    Table1:

    Table2:

    Relationship:

    Measure:

    date customer meant to pay =
    VAR _Payment_terms =
        SUM ( Table2[payment terms] )
    VAR _net_or_eom =
        MAX ( Table2[net or eom] )
    VAR _Transaction_Date =
        MAX ( Table1[Transaction Date] )
    RETURN
        IF (
            _net_or_eom = "net",
            _Transaction_Date + _Payment_terms,
            EOMONTH ( _Transaction_Date, 0 ) + _Payment_terms
        )

    Result is as below.

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

5 Replies

  • Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Russ99 ,

     

    My sample is as below.

    Table1:

    Table2:

    Relationship:

    Measure:

    date customer meant to pay =
    VAR _Payment_terms =
        SUM ( Table2[payment terms] )
    VAR _net_or_eom =
        MAX ( Table2[net or eom] )
    VAR _Transaction_Date =
        MAX ( Table1[Transaction Date] )
    RETURN
        IF (
            _net_or_eom = "net",
            _Transaction_Date + _Payment_terms,
            EOMONTH ( _Transaction_Date, 0 ) + _Payment_terms
        )

    Result is as below.

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • Russ99's avatar
      Russ99
      Helper I

      this has worked really well for a lot of my data so thanks so much for that. however the measure customer meant to pay is throwing out some results in the year 2117 and some in the year 1900, do you know why this could be?