Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
lavdeepk
Resolver I
Resolver I

Can i declare variable in Power Pivot??

Hi,

I am trying to declare variable in Power Pivot but getting error . I am not sure that i am making mistake or variable can not use in  Power Pivot??

Please help

 

1 ACCEPTED SOLUTION

Hi @lavdeepk 

The error message indicates that the DATA[QTY] is of text type while it needs to be of number type.

So, please check the type of that column and change it to number.

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @lavdeepk 

How do you declare variable in Power Pivot?

Could you show me some examples with screenshots and tell me what's the errors?

Is this you wanted?

https://powerbi.tips/2017/05/using-variables-within-dax/

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie,

 

As reqired i am sharing details with you please see Below SS.

I am able to declare variable in power bi and getting error when i use same code and same syntex in power pivot

VAR EXAMPLE =
VAR
TotalQuantity = SUM (DATA[QTY] )
RETURN
IF (
TotalQuantity > 1000,
TotalQuantity * 0.95,
TotalQuantity * 1.25
)

 

Untitled.png

 

Thanks 

Lavdeep sharma

Hi @lavdeepk 

The error message indicates that the DATA[QTY] is of text type while it needs to be of number type.

So, please check the type of that column and change it to number.

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-juanli-msft 

 

Thanks there was data type issue.Now Working fine

 

Thanks

Lavdeep

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors