Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Measure totals do not return expected values

Hi All,

 

I've a simple measure with 2 variables that calculate the sum/difference of columns from multiple tables and result is set to return min of these 2 variables, It displyed correctly in the table but the total does not show the expected value. 

 

Current output : Min (A+B, C+D) i.e., Min (6,8) = 6

Expected output : Sum of MinResult (1+1) = 2

 

I need the sum of the final MinResult as in table below

 

TIA, for your help

 

For Ex: 

 

 

# MinResult = 
VAR A+B = SUM(Table1[A])+SUM('Table2'[B])
VAR C+D = SUM(Table1[C])+SUM('Table2'[D])
VAR Result = 
    (
        MIN ( (A+B), (C+D))
    )
    Return Result

 

 

ABCDA+BC+DPseudo valueCountryMin Result (A+B , C+D)
012315US1US1
340171US2US1

 

Ashish_Mathur - could you help plz, Thank You!

 

  • Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario.

     

    You may create three measures as follows.

    AB = SUM('Table'[A])+SUM('Table'[B])
    
    CD = SUM('Table'[C])+SUM('Table'[D])
    
    MinResult = 
    SUMX(
        'Table',
        CALCULATE(MIN([AB],[CD]))
    )

     

    Result:

     

     

    Best Regards

    Allan

     

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

     

8 Replies

  • v-alq-msft's avatar
    v-alq-msft
    Community Support

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario.

     

    You may create three measures as follows.

    AB = SUM('Table'[A])+SUM('Table'[B])
    
    CD = SUM('Table'[C])+SUM('Table'[D])
    
    MinResult = 
    SUMX(
        'Table',
        CALCULATE(MIN([AB],[CD]))
    )

     

    Result:

     

     

    Best Regards

    Allan

     

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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you!!

    • Anonymous's avatar
      Anonymous
      Not applicable

      I'll try to explain the issue better this time

       

      I've a measure to return min of two variables. So, let's say for a given country, i have 2 entries, 1 for each state as below. As expected, measure returns the min values for each state (see below). Now, when i show the total value for column - 'Min value' it is showing 5 instead i.e., it is adding the values for B (5) and comparing it with A (6) and returning the minimum value of the total

       

      ABStateCountryMin value of A,B 
      12TxUS1 
      53CaUS3 
         Total5 

       

       

       

      • amitchandak's avatar
        amitchandak
        Super User

        Try like

        sumx(summarize(table,table[state],table[country], "_min",min(table[A],table[B])),[_min])

         

  • v-alq-msft's avatar
    v-alq-msft
    Community Support

    Hi, Anonymous 

     

    If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

     

    Best Regards

    Allan