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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.