Forum Discussion

akhtar0507's avatar
akhtar0507
Frequent Visitor
4 years ago
Solved

P&L Help

Hello,

 

I have finally got my report to ressemble an income statement and all my measures are working fine individually. However, when I am summing my cost of sales and cost of sales B, it is returning blank as I am assuming the total cost of sales does not have any rows in the current context. 
Here is my formula that I am trying since few days. Can you please help me out?

 

Income Statement Amount =

VAR _currentItem = SELECTEDVALUE('GL Segment'[GL Grouping])
RETURN
SWITCH(TRUE(),
_currentItem = "Sales", [GL Total Sales],
_currentItem = "Cost of Sales",[GL Cost of sales Only],
_currentItem = "Cost of Sales B", [GL Cost of sales B],
_currentItem = "Total Cost of Sales", [GL Cost of sales Only] +  [GL Cost of sales B]
)
However, individually my formula is working fine, but the problem arises when I am trying to display it in my matrix. The total is good but the measure Total Cost of Sales is returning blank.

  • PaulDBrown's avatar
    PaulDBrown
    4 years ago

    Try:

    _currentItem = "Total Cost of Sales", CALCULATE( [GL Cost of sales Only], ALL ( GL Segment )) +  CALCULATE ( [GL Cost of sales B], ALL ( GL Segment) ))
     

6 Replies

    • akhtar0507's avatar
      akhtar0507
      Frequent Visitor

      Hello PaulDBrown,

      The total contains Coat of sales B and Cost of Sales Only.

      Thank you for helping. 

      • PaulDBrown's avatar
        PaulDBrown
        Community Champion

        Right, but can post the  code for each measure?