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
snandy2011
Helper IV
Helper IV

Cannot convert value 'comedy specialOCM' of type text to type true / False

Hi All,

 

I am struggleing with a simple Dax formula which can easily done in excel but getting some problem on power bi. I just want to calculate maximum profit of all account. I have datasets like,

 

Account           Profit

A                        100

B                         100

A                         200

C                         100

D                         200

B                         100

D                         50 

 

so, here, maximum profit is belonging to A, which is 300. This simple thing I want to do by DAX. I have done this in excel. Written following formula in Dax 

 

Max Profit = CALCULATE( MAX(' Profit'[Gross Revenue]), FILTER('Profit','Profit'[ Account] ) )

 

but getting Cannot convert value 'comedy specialOCM' of type text to type true / False error.

 

can you please suggest me how to fix this formula and error?

 

Any suggesation is really appreciable.

 

Thanks,

snandy2011

 

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @snandy2011,

 

There could be two possible causes.

1.  FILTER('Profit','Profit'[ Account] ). The second parameter of FILTER should be a condition rather than a column.

2. What's 'Profit'[Gross Revenue]?  A measure or a calculated column?

The measure could be like below.

result =
MAXX (
    SUMMARIZE ( 'table', 'table'[Account], "totalProfit", SUM ( 'table'[Profit] ) ),
    [totalProfit]
)

Best Regards,

Dale

Community Support Team _ Dale
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

6 REPLIES 6
Seward12533
Solution Sage
Solution Sage

Why not just use

  Max Profit = MAX(' Profit'[Gross Revenue])

 

It should then dynamically caluclate in contex whenever you use it. So if you built a table with Account and Profit it should show the max profit by account.

 

The Summarize solution is nice it builds a table you can reference and link to your model.

 

 

 

Hi @Seward12533

 

If i use only Max Profit = MAX(' Profit'[Gross Revenue]). It's only giving me the maximum profit of all user. Check out my exapmple on question section. If i apply your formula only, it will only give me maximum profit of all user, which is 200.But from A we get profit multiple times, from B as well. So the maximum profit will be 300, which is belonging to A. So,only use the Max formula will not be the solution.

 

Thnaks,

 

snandy2011

Sorry it was late and I didn't really read your message. PowerBI/PowerPivot is a paradigm shift from classic excel. In the Example above if add a visual could be Matrix, Bar Chart, or whatever the application will figure out the context and show it correctly

 

Assuming you have sales data you will need a few measures

  Revenue = SUM(sales[Total Sales])
  Cost = SUM(sales[COGS])

  Margin = ([Revenue]-[Cost])/[Revenue]

 

If you want a dedicated measure to display the Margin for one of the accounts independently you could use the calculate with filter

 

Margin A = CALCULATE([Margin],sales[Account]="A")  which is really short for  CALCULATE([Margin],FILTER(sales,sales[Account]=A))

 

 

 

@Seward12533 Yes. You are right. On First time, I followed  your process, but i was getting above mentioned error.So, therefore,i post this question over here.Anyway, I have solved this problem.Although this is not the right process to do, but it shows the right result.

 

Thanks once again for your reply and valueable suggesation.

 

Thanks,

snandy2011

v-jiascu-msft
Employee
Employee

Hi @snandy2011,

 

There could be two possible causes.

1.  FILTER('Profit','Profit'[ Account] ). The second parameter of FILTER should be a condition rather than a column.

2. What's 'Profit'[Gross Revenue]?  A measure or a calculated column?

The measure could be like below.

result =
MAXX (
    SUMMARIZE ( 'table', 'table'[Account], "totalProfit", SUM ( 'table'[Profit] ) ),
    [totalProfit]
)

Best Regards,

Dale

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

Hi @v-jiascu-msft

 

Sorry for late replying..Profit'[Gross Revenue] is measure.

 

I am going through your solution.It it solves i will let you know.

 

Thank you very much for your suggesation.

 

Thanks,

 

snandy2011

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.