Forum Discussion

luisrossa8's avatar
luisrossa8
Regular Visitor
2 years ago
Solved

Help with wrong totals in matrix

Hi,

In short my issue is I get wrong row and column total in a matrix if I use a measure to compute the value of the sales.

 

 

The data table is on the left.

 

On the right the first matrix has the totals correct.

The second matrix is not computing the totals right.

In this second matrix I used a measure like:

TotalSalesModified = if(SELECTEDVALUE(Sales[Item])="a" && SELECTEDVALUE(Sales[Month])="jan" ,99, sum(Sales[Sales]))

In the first one:

TotalSales = sum(Sales[Sales])

 

Can you help ?

 

Thanks in advance.

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hello luisrossa8 

     

    For your question, I have created the following table.

     

     

    Your original matrix looks like this:

     

    You can use the following dax function to get the effect you want

    TotalSalesModified = 
    SUMX(
        Sales, 
        IF(
            Sales[Item] = "aa" && Sales[Month] = "jan", 
            99, 
            Sales[Sales]
        )
    )
    

     

     

     

     

    Best Regards,

    Jayleny

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

4 Replies

    • luisrossa8's avatar
      luisrossa8
      Regular Visitor

      Thank you for your help.

      I'll see, as your suggestion, what Alberto has to say.

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello luisrossa8 

     

    For your question, I have created the following table.

     

     

    Your original matrix looks like this:

     

    You can use the following dax function to get the effect you want

    TotalSalesModified = 
    SUMX(
        Sales, 
        IF(
            Sales[Item] = "aa" && Sales[Month] = "jan", 
            99, 
            Sales[Sales]
        )
    )
    

     

     

     

     

    Best Regards,

    Jayleny

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

    • luisrossa8's avatar
      luisrossa8
      Regular Visitor

      Hi,

      Thank you for your DAX.

      Works fine as expected.

      Five stars !!!!