Forum Discussion

UncleLewis's avatar
UncleLewis
Icon for Responsive Resident rankResponsive Resident
4 years ago

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

  • 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.

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity 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])
    )
  • v-xiaotang's avatar
    v-xiaotang
    Icon for Community Support rankCommunity 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] ) )

     

     

    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