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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Argument 4 Calculate formula Error

Hi Experts

 

I cannot find the error in the following DAX...

CY =

SWITCH(

    SELECTEDVALUE('DimP&L'[Item]),

    "Gross Sales", SUM('Sales&Ohd_Data_Master'[Gross_Sales_USD])/1000,

    "Rebate", CALCULATE(SUM('Sales&Ohd_Data_Master'[Local_Rebates_USD])/1000, REMOVEFILTERS('DimP&L')),

    "Stock Cleanse", CALCULATE(SUM('Sales&Ohd_Data_Master'[Stock_Cleanse_USD])/1000, REMOVEFILTERS('DimP&L')),

    "Net Sales", CALCULATE(SUM('Sales&Ohd_Data_Master'[Net_Sales_USD])/1000, REMOVEFILTERS('DimP&L')),

    "COGS", CALCULATE(SUM('Sales&Ohd_Data_Master'[Gross_Cost_USD])/1000, REMOVEFILTERS('DimP&L')),

    "Gross Margin", CALCULATE(SUM('Sales&Ohd_Data_Master'[Factory_Margin_USD])/1000, REMOVEFILTERS('DimP&L')),

    "WD", CALCULATE(SUM('Sales&Ohd_Data_Master'[8.SC&L True-up])/1000, REMOVEFILTERS('DimP&L')),

    "OCOGS", CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Indirect])/1000,         REMOVEFILTERS('DimP&L')),

    "IBG", CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Indirect])/1000, REMOVEFILTERS('DimP&L')),

    "Contribution Margin", CALCULATE(SUM('Sales&Ohd_Data_Master'[Factory_Margin_USD])/1000-CALCULATE(SUM('Sales&Ohd_Data_Master'[8.SC&L True-up])/1000-CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Indirect])/1000)-CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Indirect])/1000, REMOVEFILTERS('DimP&L')),

    "Manufacturing & Engineering", CALCULATE(SUM('Sales&Ohd_Data_Master'[MFG+ENG+OCOGS Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[MFG+ENG+OCOGS Indirect])/1000, REMOVEFILTERS('DimP&L')),

    "SG&A", CALCULATE(SUM('Sales&Ohd_Data_Master'[SG&A Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[SG&A Indirect])/1000, REMOVEFILTERS('DimP&L')),

    "D&A", CALCULATE(SUM('Sales&Ohd_Data_Master'[D&A Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[D&A Indirect])/1000, REMOVEFILTERS('DimP&L')),

    "OI", CALCULATE(SUM('Sales&Ohd_Data_Master'[OI])/1000, REMOVEFILTERS('DimP&L')),

))))))))))

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like

 

SWITCH(

SELECTEDVALUE('DimP&L'[Item]),

"Gross Sales", SUM('Sales&Ohd_Data_Master'[Gross_Sales_USD])/1000,

"Rebate", CALCULATE(SUM('Sales&Ohd_Data_Master'[Local_Rebates_USD])/1000, REMOVEFILTERS('DimP&L')),

"Stock Cleanse", CALCULATE(SUM('Sales&Ohd_Data_Master'[Stock_Cleanse_USD])/1000, REMOVEFILTERS('DimP&L')),

"Net Sales", CALCULATE(SUM('Sales&Ohd_Data_Master'[Net_Sales_USD])/1000, REMOVEFILTERS('DimP&L')),

"COGS", CALCULATE(SUM('Sales&Ohd_Data_Master'[Gross_Cost_USD])/1000, REMOVEFILTERS('DimP&L')),

"Gross Margin", CALCULATE(SUM('Sales&Ohd_Data_Master'[Factory_Margin_USD])/1000, REMOVEFILTERS('DimP&L')),

"WD", CALCULATE(SUM('Sales&Ohd_Data_Master'[8.SC&L True-up])/1000, REMOVEFILTERS('DimP&L')),

"OCOGS", (CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"IBG", (CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"Contribution Margin", (CALCULATE(SUM('Sales&Ohd_Data_Master'[Factory_Margin_USD])/1000)-CALCULATE(SUM('Sales&Ohd_Data_Master'[8.SC&L True-up])/1000)-CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Indirect])/1000)-CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"Manufacturing & Engineering", (CALCULATE(SUM('Sales&Ohd_Data_Master'[MFG+ENG+OCOGS Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[MFG+ENG+OCOGS Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"SG&A", CALCULATE(SUM('Sales&Ohd_Data_Master'[SG&A Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[SG&A Indirect])/1000, REMOVEFILTERS('DimP&L')),

"D&A", CALCULATE(SUM('Sales&Ohd_Data_Master'[D&A Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[D&A Indirect])/1000, REMOVEFILTERS('DimP&L')),

"OI", CALCULATE(SUM('Sales&Ohd_Data_Master'[OI])/1000, REMOVEFILTERS('DimP&L')),

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi Amit where was my error???

@Anonymous , Quite a few places calculate was not ending that selection. and closed them all at end

 

example

 

"OCOGS", CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Indirect])/1000, REMOVEFILTERS('DimP&L')),

"IBG", CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Direct])/1000+CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Indirect])/1000, REMOVEFILTERS('DimP&L')),

 

They are not closing properly

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@Anonymous , Try like

 

SWITCH(

SELECTEDVALUE('DimP&L'[Item]),

"Gross Sales", SUM('Sales&Ohd_Data_Master'[Gross_Sales_USD])/1000,

"Rebate", CALCULATE(SUM('Sales&Ohd_Data_Master'[Local_Rebates_USD])/1000, REMOVEFILTERS('DimP&L')),

"Stock Cleanse", CALCULATE(SUM('Sales&Ohd_Data_Master'[Stock_Cleanse_USD])/1000, REMOVEFILTERS('DimP&L')),

"Net Sales", CALCULATE(SUM('Sales&Ohd_Data_Master'[Net_Sales_USD])/1000, REMOVEFILTERS('DimP&L')),

"COGS", CALCULATE(SUM('Sales&Ohd_Data_Master'[Gross_Cost_USD])/1000, REMOVEFILTERS('DimP&L')),

"Gross Margin", CALCULATE(SUM('Sales&Ohd_Data_Master'[Factory_Margin_USD])/1000, REMOVEFILTERS('DimP&L')),

"WD", CALCULATE(SUM('Sales&Ohd_Data_Master'[8.SC&L True-up])/1000, REMOVEFILTERS('DimP&L')),

"OCOGS", (CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"IBG", (CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"Contribution Margin", (CALCULATE(SUM('Sales&Ohd_Data_Master'[Factory_Margin_USD])/1000)-CALCULATE(SUM('Sales&Ohd_Data_Master'[8.SC&L True-up])/1000)-CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[9.OCOGS_Indirect])/1000)-CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[11f IBG_Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"Manufacturing & Engineering", (CALCULATE(SUM('Sales&Ohd_Data_Master'[MFG+ENG+OCOGS Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[MFG+ENG+OCOGS Indirect])/1000, REMOVEFILTERS('DimP&L'))),

"SG&A", CALCULATE(SUM('Sales&Ohd_Data_Master'[SG&A Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[SG&A Indirect])/1000, REMOVEFILTERS('DimP&L')),

"D&A", CALCULATE(SUM('Sales&Ohd_Data_Master'[D&A Direct])/1000)+CALCULATE(SUM('Sales&Ohd_Data_Master'[D&A Indirect])/1000, REMOVEFILTERS('DimP&L')),

"OI", CALCULATE(SUM('Sales&Ohd_Data_Master'[OI])/1000, REMOVEFILTERS('DimP&L')),

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.