Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Dax calculation help

Hello, 

 

I need somehelp on Dax calulation. Below is the sample data:

 

I have dataset like below. 

DepartmentGradeNo of Emp
ITA90
ITB90
ITC90
HRA10
HRB5
HRC1
NonITA4
NonITB16
NonITC0
SecurityA5
SecurityB3
SecurityC2

 

Required output is below:

DepartmentNo of Emp
IT90
HR16
NonIT20
Security10

 

Only for 'IT' department i dont want to do the sum of 'No of Emp' column but for all other departments I want to do the sum on 'No of Emp' and display the value. As you can see for IT the value is same 90 in source dataset and output table but for HR in the output table it is 20 (10+5+1). 

 

Can someone please advice how I can get this. Please let me know if I am not clear.

Thank you.

  • Anonymous  In that case, create a new measure as below

     

    Test288 = 
    VAR _IT = MAXX(FILTER(Test288SumIF,Test288SumIF[Department]="IT"),Test288SumIF[NoOfEmp])
    VAR _Other = SUMX(Test288SumIF,Test288SumIF[NoOfEmp])
    RETURN IF(SELECTEDVALUE(Test288SumIF[Department])="IT",_IT,_Other)

4 Replies

  • PattemManohar's avatar
    PattemManohar
    Community Champion

    Anonymous  Please try this as a New Table.

     

    Test288Out = SUMMARIZE(Test288SumIF,Test288SumIF[Department],"Count",IF(Test288SumIF[Department]="IT",MAX(Test288SumIF[NoOfEmp]),SUM(Test288SumIF[NoOfEmp])))

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi PattemManohar ,

       

      Thank you its working but the other thing I would like to add is I want to show 'Department' and 'Grade' as slicers. So when the user select Department = IT and Grade = All then it should show 90 and even if the user select a particular grade lets say 'A' and department = IT it should show 90 only. Any chance its possible please? 

       

      Many Thanks

      • PattemManohar's avatar
        PattemManohar
        Community Champion

        Anonymous  In that case, create a new measure as below

         

        Test288 = 
        VAR _IT = MAXX(FILTER(Test288SumIF,Test288SumIF[Department]="IT"),Test288SumIF[NoOfEmp])
        VAR _Other = SUMX(Test288SumIF,Test288SumIF[NoOfEmp])
        RETURN IF(SELECTEDVALUE(Test288SumIF[Department])="IT",_IT,_Other)