Forum Discussion

SQUILES's avatar
SQUILES
Helper I
5 years ago
Solved

Total Sales Payment

Hi Everyone... 

I have a total of sales and I have a reference table with the range to calculate the payment for total sales. I use this calculated formula, but I think is no the best way, and I want to use ref_table.

PAYMENT = CALCULATE(IF(AND ([TOTAL VENTAS]>=1, [TOTAL VENTAS]<=19),0,
IF(AND ([TOTAL VENTAS]>=20, [TOTAL VENTAS]<=29),800,
IF(AND ([TOTAL VENTAS]>=30, [TOTAL VENTAS]<=39),1200))))

Example:

 


REF_PAYMENT_TABLE




  • This should give you what you are looking for...
     
    Lookup_Value = CALCULATE( VALUES( 'Table (5)'[Value] ), FILTER('Table (5)', 'Table (6)'[Sales#] >= 'Table (5)'[From] && 'Table (6)'[Sales#] <= 'Table (5)'[To]))

     

     

     

3 Replies

  • fhill's avatar
    fhill
    Resident Rockstar
    This should give you what you are looking for...
     
    Lookup_Value = CALCULATE( VALUES( 'Table (5)'[Value] ), FILTER('Table (5)', 'Table (6)'[Sales#] >= 'Table (5)'[From] && 'Table (6)'[Sales#] <= 'Table (5)'[To]))

     

     

     

    • SQUILES's avatar
      SQUILES
      Helper I

      may not mention it, Sale# come from a count. The original data is SaleName and a DATE of the Sales. 

      With you calculate formula I don't have a Total at the end of the column.

  • SQUILES add new column using following DAX:

     

    Column = 
    VAR __sales = 'Table'[Sales]
    RETURN
    CALCULATE ( MIN ( Range[Amount] ), __sales  >= Range[Min], __sales <= Range[Max] )

     

    Follow us on LinkedIn

     

    Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.