Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Expressions that yield variant data-type cannot be used (multiply with constant value)

Hello,

 

Could you help with DAX for below situation.

IF(OR(All_Data_View[supplier_name]="ABC",All_Data_View[supplier_name]="XYZ"),
SUMX(All_Data_View,All_Data_View[part_qty])*(12))
 
Where 12 is constant value.
 
Thanks,
CS

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Anonymous 

    Make sure the datatypes are setup correctly in the power query editor. (QTY as wholenumber)

    With your test data the following measure worked for me:

    Column =
    IF (
        All_Data_View[Shipping Site] = "XYZ",
        All_Data_View[Part Qty] * 15.2,
        IF (
            All_Data_View[Shipping Site] = "ABC"
                && All_Data_View[Part Qty] < 100,
            All_Data_View[Part Qty] * 10,
            50
        )
    )

     

    Kind regards
    Joren Venema

    Data & Analytics Consultant
    If this reply solved your question be sure to mark this post as the solution to help others find the answer more easily. 

     

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous 

    If this is a measure this is not gonna work regardless. The IF statement is not iterating the table and you should use a filter.

    From what I can tell this code should result in the same output:

    Measure =
    CALCULATE (
        SUM ( All_Data_View[part_qty] ) * 12,
        All_Data_View[supplier_name] = "ABC"
            || All_Data_View[supplier_name] = "XYZ"
    )

     

    Hope this helps.

     

    Kind regards
    Joren Venema

    Data & Analytics Consultant
    If this reply solved your question be sure to mark this post as the solution to help others find the answer more easily. 

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

      Thanks for your reply!

       

      I am trying to calculate transaction fee in single new column using "nested if" for set of data value, and this among one condition.

      If there any other way to get this condition worked along with others in same column.

       

      Regards,

      CS

       

      • amitchandak's avatar
        amitchandak
        Super User

        Can you share sample data and sample output. Mark me @