Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi ALL,
I have a column Amount but it is in varchar datatype but here my problem is I have to calculate the average of the Amount
table A (Id, Amount)
1 10.00
2 20.00
3 50.00
1 15.00
2 25.00
3 55.00
Average of all customer = Average(Table A[Amount]) but here the Amount is in varchar data type and I am using SQL Server as a direct query result =(10+20+50+15+25+55)/3=58.33
Solved! Go to Solution.
In a direct query, you have to use another option cast to a number. By *1 or by bring number from DB
Hi, @manideep547
Based on your description, you can use Value function to convert from text to number when it is calculated. Therefore, you may create a measure as follows.
AverageMeasure =
DIVIDE(
SUMX(
'Table A',
VALUE('Table A'[Amount])
),
DISTINCTCOUNT('Table A'[Id])
)
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.
Hi, @manideep547
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
Hi, @manideep547
Based on your description, you can use Value function to convert from text to number when it is calculated. Therefore, you may create a measure as follows.
AverageMeasure =
DIVIDE(
SUMX(
'Table A',
VALUE('Table A'[Amount])
),
DISTINCTCOUNT('Table A'[Id])
)
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.
Why you can not change the data type in power BI.
Try Averagex(table, Amount*1.0), If it error, then filter the table for those items
like
Averagex(filter(table,not(isblank(amount)), Amount*1.0),
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
@amitchandak For direct query can we change the data type?
can you please suggest me if how can change the data type for a column in direct query mode?
thank you.
@amitchandak Is there is an option to change the mode from import to direct query?
Hi, @manideep547
It is unsupported to change from import to DirectQuery mode. While it is possible to switch a model from DirectQuery mode to use import mode, all the necessary data must be imported. It's also not possible to switch back, primarily because of the set of features not supported in DirectQuery mode.
For further information, you may refer to the following link.
https://docs.microsoft.com/en-us/power-bi/desktop-directquery-about
Best Regards
Allan
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
71 | |
70 | |
43 | |
31 | |
26 |
User | Count |
---|---|
89 | |
49 | |
44 | |
38 | |
37 |