cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
chandrashekarc
Helper III
Helper III

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

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@chandrashekarc 

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. 

 

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

@chandrashekarc 

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. 

 

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

 

Anonymous
Not applicable

@chandrashekarc 

I'm still not a 100% sure if you are doing this as a measure or as a calculated column.

In case of a measure try and nest the if statement in the sumx like this:

SUMX ( All_Data_View, IF ( All_Data_View[supplier_name]="ABC" || All_Data_View[supplier_name]="XYZ", All_Data_View[part_qty] *12, <alternative> ) )

Incase of a column it will always iterate and should work like this:

IF ( All_Data_View[supplier_name]="ABC" || All_Data_View[supplier_name]="XYZ", All_Data_View[part_qty] *12, <alternative> ) 

 

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. 

 

 

Hi Joren, Thanks!

I am doing this in new column, and still get this error "Expressions that yield variant data-type cannot be used to define calculated columns"

 

Regards,

CS

 

Anonymous
Not applicable

@chandrashekarc 

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. 

 

View solution in original post

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

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Hi Amitchandak,

 

Here is the sample data.

And i am looking at output as:

If shipping site=XYZ, then (Part Qty)*15.12

else if shipping site=ABC and (Part Qty)<100, then  (Part Qty)*10 else 50

 

Claim N°Claim statusPart N°Part descriptionPart QtyExtended Item valueShipping SiteTransaction_Fee
1CLOSED836308SPS-KYBD BL W/PT STK 14-FR25733.5XYZ237.5
2CLOSED826630SPS-KEYBOARD BACKLIT W/POINT STICK FR20583XYZ190
3CLOSED929985TOP COVER, W/KB PRVCY EURO2216.5ABC19
4CLOSEDL17971SPS-KYBD SR BL 15W GR129.02ABC9.5
5CLOSED922749KB, BASE TR CP BL CLLB SWIS22169.32ABC19
6CLOSED934597Assy, Stand, Yoshi10.01XYZ9.5
7CLOSED901771P/S,SFF,180W ENTL17,85% EFF HV,12V 1OT20293.2XYZ190
8CLOSED848311SPS-KYBD TP BL BEL 30897.3ABC285
9CLOSED929985TOP COVER, W/KB PRVCY EURO1108.25XYZ9.5
10CLOSEDL15540SPS-KYBD SR BL 14W EUROA5127.04XYZ9.5

 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors