cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sreekar18
Frequent Visitor

Calculated column for direct query

I have View from direct query ,based on two columns i'm calucating percentage using the below formula


Percentag =
var dr=CALCULATE(sum('ABCR_Consolidated_View'[Final_Count]))
return if(dr=0,blank(),'ABCR_Consolidated_View'[Delta]/dr*100)

but i'm getting the following error

Function 'SUM' is not allowed as part of calculated column DAX expressions on DirectQuery models

 

is there anyway to do it in direct query model.

1 ACCEPTED SOLUTION

Accepted Solutions
sreekar18
Frequent Visitor

Re: Calculated column for direct query

@Icey thanks for the solution

In my case I'm getting some error so i used the divide function to solve the problem.

Delta1 = DIVIDE ( SUM ( 'ABCR_Consolidated'[Delta]), SUM ('ABCR_Consolidated'[Final_Count] ) )

View solution in original post

6 REPLIES 6
Super User II
Super User II

Re: Calculated column for direct query

Hi @sreekar18 

try a measure, not calculated column


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Super User IV
Super User IV

Re: Calculated column for direct query

Columns are nor supported. Measures are. Refer my article how to handle these look for net sales , gross sales, and discount

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-1-Time-Intell...





Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


Super User I
Super User I

Re: Calculated column for direct query

https://docs.microsoft.com/en-us/power-bi/desktop-directquery-about

 

Quoting:

"Limitations in calculated columns: Calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions. Additionally, the DAX scalar functions, such as LEFT(), that are allowed, are limited to those functions that can be pushed to the underlying source. The functions vary depending upon the exact capabilities of the source. Functions that aren't supported aren't listed in autocomplete when authoring the DAX for a calculated column, and would result in an error if used."





Did I answer your question? Mark my post as a solution!

PLEASE follow these instructions to ask your questions!


Proud to be a Super User!




Community Support
Community Support

Re: Calculated column for direct query

Hi @sreekar18 ,

 

Try this to create a measure:

Percentag =
VAR dr =
    CALCULATE ( SUM ( 'ABCR_Consolidated_View'[Final_Count] ) )
RETURN
    IF ( dr = 0, BLANK (), MAX ( 'ABCR_Consolidated_View'[Delta] ) / dr * 100 )

 

Please tell me if it works.

 

 

Best Regards,

Icey

 

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

sreekar18
Frequent Visitor

Re: Calculated column for direct query

@Icey thanks for the solution

In my case I'm getting some error so i used the divide function to solve the problem.

Delta1 = DIVIDE ( SUM ( 'ABCR_Consolidated'[Delta]), SUM ('ABCR_Consolidated'[Final_Count] ) )

View solution in original post

Community Support
Community Support

Re: Calculated column for direct query

Hi @sreekar18 ,

 

Glad to hear that. Please accept your reply as a solution so that people who may have the same question can get the solution directly.

 

 

Best Regards,

Icey

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors