Forum Discussion

rajasekar_o's avatar
rajasekar_o
Icon for Helper V rankHelper V
1 year ago

Total sales showing wrong

hi team,
i have calculate sales value after converting tha value in to some persentage 

eache sales value is diffrent branches.

calculation 
sales=[salesamount]-sales return amount]
convertion =sum(convert[salconv])
sales net=[salesamount]-sales return amount])*[convertion]

total sales net need to show =236355464

 

2 Replies

  • Hi rajasekar_o 

    The issue you're experiencing with calculating sales values is due to how Power BI handles totals. By default, Power BI applies contextual logic for totals, which means it does not simply sum the individual rows you see. Instead, it removes the visual-level filters and recalculates the total based on that broader context, which can lead to discrepancies.

    Alternative Solution Using `SUMX`:

    To overcome this, you can rewrite your measure using `SUMX`. This function iterates over each row in a table, allowing you to control the calculation for each row and then sum those values to get the correct total. Here’s how you could modify your calculation:

    DAX
    Sales Net = SUMX(
    SalesTable,
    ([SalesAmount] - [SalesReturnAmount]) * [Conversion]
    )
    ```

    In this example, `SUMX` will handle each row individually, performing the calculation and ensuring that your total is accurate, reflecting the sum of the row-level results rather than recalculating without the filters.

    **Helpful Video Resources:**
    For a more in-depth explanation, you might find these videos helpful:
    https://www.youtube.com/watch?v=J2FTRqrx0m0&t=2s

    https://www.youtube.com/watch?v=6rgAkejrup8&t=13s ( a little long , but very recommended)

    For more specific suggestions 

    you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

    How to Get Your Question Answered Quickly  

     

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

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, rajasekar_o 

     

    Can you explain what calculations led to your desired output?

    The sum of Sales net is not 236355464.

     

    Best Regards,

    Community Support Team _Charlotte

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