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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Sandeep
Helper I
Helper I

Calculated measures in Power BI Live connector

Hi Team,

 

I am facing an issue while creating custom columns /calculated measures for below commands in Power BI Desktop: 

 

For example:

 

Custom Column name: SalesAmtTot

Formula should be: (COUNT([SalesAmt]) - SUM([SalesAmt]))/COUNT([SalesAmt])

 

While applying the formula, it is saying this COUNT function does not exists.

 

Can someone guide me on the above..

 

Thanks in advance.

 

Thanks

Sandeep

8 REPLIES 8
Sandeep
Helper I
Helper I

Hi Team,

 

I am good now how to create calculated measures without custom columns but seems I am unable create another calculated measures on the top of the calculated measure which was created previously.

 

For Example:

 

Col 0 : Table Column

Col 1: Table Column

Col 2: Created calculated column based on  Col1. (For Say Col2 = Sum(Col 1) - Which is fine..

 

But When I am trying to create Col 3 on top of Col2 ..

Like this:

 

Col 3: To be created a calculated Column on Col 2 (For say Col 3 = Count(Col2) - Sum (Col 0) / Count(Col2))

In Power BI, in function/Dax bar, it is not whosing Col 2 to generate Col 3.

 

Hope this is much clear.

Please guide.

 

Thanks in advance.

 

Thanks,

Sandeep 

Are you trying creating a measure or a calculated column?

Maybe you should paste your original code definition (i.e. as a measure will always be referenced in [ ] )

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi Imke Feldmann,

 

I am trying to create calculated measure on the top of another calculated measure.

 

I gave a code example in the above post. could you please have a look into the above code.

 

btw, when you say, measure or a calculated column, how it is different in Power BI.

 

Thanks

Sandeep

What you describe seems to be an unlikely issue if all formulas are used correctly.
Can you please post your exact formulas (not simplified to col0, col1 etc., but the actual formula from your file) for each column and measure?
Also, the exact error message would help a lot, too.

Hi Fso,

 

Here is the formula I wanted to apply:

Just assume, there is a column named SalesAmt in Sales table.

 

We need following calculations on the Power BI Desktop:

 

(Calculated measure 1)

 

TotalSales:  = SUM (SalesAmt) -- which seems to be fine with direct query.

But while I am trying to create a new measure on the top of TotalSales, Power BI is not showing the "TotalSales" Column to create another measure on top of TotalSales.

 

(Calculated measure 2)

 

TotalSales % = (SUM(TotalSales) / Count (TotalSales)) * 100 -- Similar to this formula

 

How to handle this kind of scenario. kindly note that I am using direct query mode.

 

Thanks

Sandeep

Mi2n
Microsoft Employee
Microsoft Employee

The Count() function only accepts  a column name as an argument. Try to use a column name directly instead of using another measure.

Anonymous
Not applicable

Hello @Sandeep

 

I think the best way to achieve it, is to rewrite the first measure in the second one. To explain it, I'm using you code :

 

You have your 1st measure : total Sale = SUM(Sales Amt)

You have your 2nd measure : Total sale % = (Sum(Total Sale) / Count(Total Sale)) *100

You should to this I guess : Total Sale % =(Sum(Sales Amt) / Count(Sales Amt)) * 100

 

With the measure you want to write, on the highest level of your analysis, the result if wrong, because the Count(Total Sale) = 1 row (aggregate function), and so, the % won't be correct I guess.

 

Hope it helps, and sorry if I'm not really clear in my explaination.

 

Sebastien

 

http://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

Sorry, I have no solution for your problem.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.