Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Incorrect Totals for Measured Column

I am currently creating a report that shows a cost of goods, rebated cost of goods, and true cost of goods column. The picture posted below shows the measure I created for the true cost of goods. However, the totals for the column are way off. Is there an issue with the measure I created that would be causing this problem? The totals at the bottom should be closer to the $400,000 mark and not the $152 million it is currently showing. 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    I think [other_cost x qty_shipped] should be a measure, due to you can use it directly in your IF code.

    I update your code, please try this.

    True Cost 1= 
    SUMX (
        SUMMARIZE (
            p21_view_invoice_line,
            p21_view_invoice_line[cogs_amount],
            "other_cost x qty_shipped", [other_cost x qty_shipped],
            "@Cost",
                IF (
                    p21_view_invoice_line[other_cost x qty_shipped] = 0,
                    SELECTEDVALUE ( p21_view_invoice_line[cogs_amount] ),
                    p21_view_invoice_line[other_cost x qty_shipped]
                )
        ),
        [@Cost]
    )

    In my sample it works. Result is as below.

    You can download my sample for more details.

     

    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.

     

6 Replies

  • Anonymous you need to share the DAX measure expression you are using, and how the tables are connected.

     

    Read this post to get your answer quickly.

    https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

     

    Follow us on LinkedIn and  to our YouTube channel

     

    Learn about conditional formatting at Microsoft Reactor

    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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Here is the measure that I am using for the column. 

     

    True Cost =
    IF (
    p21_view_invoice_line[other_cost x qty_shipped] = 0,
    SELECTEDVALUE ( p21_view_invoice_line[cogs_amount] ),
    p21_view_invoice_line[other_cost x qty_shipped]
    )
     
    Both of these fields are from the same table p21_view_invoice_line
     
    Is this all you need parry2k ? 
  • Anonymous whatever columns you have on the rows, put that in the summarize:

     

    rue Cost =
    SUMX (
    SUMMARIZE ( Table, Table[Column1 On Row], Table[Column 2 Row], 
    "@Cost", IF (
    p21_view_invoice_line[other_cost x qty_shipped] = 0,
    SELECTEDVALUE ( p21_view_invoice_line[cogs_amount] ),
    p21_view_invoice_line[other_cost x qty_shipped]
    ),
    [@cost]
    )
     

     

    Follow us on LinkedIn and  to our YouTube channel

     

    Learn about conditional formatting at Microsoft Reactor

    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I attempted to use that DAX expression below and I was getting the error, "Too few arguments were passed to the SUMX function. The minimum argument count for the function is 2."

       

      True Cost = SUMX (
      SUMMARIZE ( p21_view_invoice_line, p21_view_invoice_line[cogs_amount], p21_view_invoice_line[other_cost x qty_shipped],
      "@Cost", IF (
      p21_view_invoice_line[other_cost x qty_shipped] = 0,
      SELECTEDVALUE ( p21_view_invoice_line[cogs_amount] ),
      p21_view_invoice_line[other_cost x qty_shipped]
      ),
      [@Cost]
      ))

       

      I also put that expression into DAX formatter and was getting a syntax error. I have included that as well.

       

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        I think [other_cost x qty_shipped] should be a measure, due to you can use it directly in your IF code.

        I update your code, please try this.

        True Cost 1= 
        SUMX (
            SUMMARIZE (
                p21_view_invoice_line,
                p21_view_invoice_line[cogs_amount],
                "other_cost x qty_shipped", [other_cost x qty_shipped],
                "@Cost",
                    IF (
                        p21_view_invoice_line[other_cost x qty_shipped] = 0,
                        SELECTEDVALUE ( p21_view_invoice_line[cogs_amount] ),
                        p21_view_invoice_line[other_cost x qty_shipped]
                    )
            ),
            [@Cost]
        )

        In my sample it works. Result is as below.

        You can download my sample for more details.

         

        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.