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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
UncleLewis
Responsive Resident
Responsive Resident

Cannot Add Meausre To Visual

Hi all,

 

Using PBIDS 2.97 Sept, 2021.

I created a measure to get Total Sales By Profit Center - no errors in Meausre

However when I try to add it to a visual, I get an error:

 

Error Message:
MdxScript(Model) (8, 9) Calculation error in measure ' Measures'[Total Sales By Store]: Cannot convert value 'PC001' of type Text to type True/False.

 

My measure:

Total Sales By Store =
CALCULATE(
[Total Sales],
Sales[Profit_Center]
)
 

What am I doing wrong?

 

Thanks,

-w

 

 

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @UncleLewis 

Thanks for reaching out to us.

 

Have you solved your problem with the above answers? 

If not, could you share the code of [Total Sales]? This error usually occurs when you make a bool judgment on the value of text type.

Or try this,

Total Sales By Store =
CALCULATE ( SUM ( Sales[Sales] ), ALLEXCEPT ( Sales, Sales[Profit_Center] ) )

vxiaotang_0-1635220714751.png

 

 

Best Regards,

Community Support Team _Tang

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

parry2k
Super User
Super User

@UncleLewis not sure what you are trying to do, if I understood it correctly, you want to see total sales by profit center. As @AllisonKennedy  recommended, you don't need to do anything since you already have a measure called Total Sales

 

In a table visual, drop Profit Center column and Total Sales measure and it should work.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

AllisonKennedy
Community Champion
Community Champion

@UncleLewis you can just use Profit Center in the visual you don't need a measure to do this unless you want the subtotal, in which case you need to use the ALL function:

 

Total Sales By Store =
CALCULATE(
[Total Sales],
ALL(Sales[Profit_Center])
)

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.