Forum Discussion

kky1's avatar
kky1
Helper II
2 years ago
Solved

Argument 3 in CALCULATE function is required - syntax error?

Hello community - I am getting the error "Argument 3 in CALCULATE function is required for this DAX measure. Reading other posts, most of these appear to be a syntax such  as an extra comma but I am having trouble spotting it in my code. Can anyone assist?

 

Gender All or selectedInstitutiton_v2: = //used table and measures so there is space between bars on bar charts
//need this so that bar chart retains percentage when only 1 gender selected
VAR __selectedID  = SELECTEDVALUE('parameterInstitution'[shortDisplayName])  
RETURN
IF (
    __selectedID = 'parameterInstitution'[SlicerSelection] && __selectedID in VALUES('Dim_Institutions'[shortDisplayName]),
VAR __selectedUnitID =
CALCULATE(
    MAX('Faculty IPEDS Diversity'[UNITID]),
     'Dim_Institutions'[shortDisplayName] = __selectedID
)
VAR __selected_gender_sel =
CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count]),
    'Peer Groups'[UnitID]=__selectedUnitID, //variable selectedInstitution
)
VAR __all_sel=
CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count]),
    'Peer Groups'[UnitID]=__selectedUnitID, //variable selectedInstitution
    ALL('Faculty IPEDS Diversity'[Sex])
)
VAR __psu=
DIVIDE(
    __selected_gender_sel, __all_sel
)
VAR __selected_gender_all =
CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count])
)
VAR __allgender=
CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count]),
    ALL('Faculty IPEDS Diversity'[Sex])
)
VAR __all=
DIVIDE(
    __selected_gender_all, __allgender
)
VAR __selection=
SELECTEDVALUE('PSU/All Slicer Table'[Sort])
RETURN
SWITCH(
    TRUE(),
    __selection = 1, __psu,
    __selection = 2, __all
))
 

Thank you kky1 

  • kky1 , remove comma in this

     

    VAR __selected_gender_sel =
    CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count]),
    'Peer Groups'[UnitID]=__selectedUnitID, //variable selectedInstitution
    )

     

     

    like

     

     

    VAR __selected_gender_sel =
    CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count]),
    'Peer Groups'[UnitID]=__selectedUnitID //variable selectedInstitution
    )

2 Replies

  • kky1 , remove comma in this

     

    VAR __selected_gender_sel =
    CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count]),
    'Peer Groups'[UnitID]=__selectedUnitID, //variable selectedInstitution
    )

     

     

    like

     

     

    VAR __selected_gender_sel =
    CALCULATE(
    SUM('Faculty IPEDS Diversity'[Count]),
    'Peer Groups'[UnitID]=__selectedUnitID //variable selectedInstitution
    )

  • Thanks so much amitchandak - that was the ticket! Much appreciated for your quick eye on that!!