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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Charles-C
Regular Visitor

Use a calculated measure with a condition

Hi,

 

I need some help and guidance please.

 

I have the below table with an Employee, Manager, and sales. For every manager there is a Supervisor and as you will see there is $0 sales for each of the supervisors. The Supervisors totals are measured on all the sales done by their team i.e.: Employee “D” should have a total sales value of $2170 similarly Employee “O” should have a total sales amount of $1993.

 

I can’t use an IF or a SWITCH formula as I cannot reference the Employee in the formula.

 

Sales with Supervisor =

IF(

    'Dim Employee'[Employee] = "D", --This produces and error which is expected

    [Sales AB],

    [Sales]]

)

 

How can I get the total sales per manager to reflect for the respective Supervisor and for the rest of the employees their normal sales?

 

Supervisor to reflect Manager totals.png

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Charles-C 

According to your description, you want to calculate the "Supervisor" sales.

Here are the steps you can refer to :
(1)If you want to show in the measure , you just need to put the fields on the visual. And you can use this measure to show the Supervisor Name:

Manager Name = CALCULATE( MAX('Table'[Employee]) , 'Table'[Role]="Supervisor")

vyueyunzhmsft_0-1678672623220.png

(2)If you want to create a calcualted column in your table , you can use this dax code:

Column = var _cur_manager =[Manager]
var _sum = SUMX(FILTER('Table','Table'[Manager] = _cur_manager) , [Sales])
return
IF([Role]="Supervisor"  ,_sum ,[Sales])

 

vyueyunzhmsft_1-1678672665571.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
v-yueyunzh-msft
Community Support
Community Support

Hi , @Charles-C 

According to your description, you want to calculate the "Supervisor" sales.

Here are the steps you can refer to :
(1)If you want to show in the measure , you just need to put the fields on the visual. And you can use this measure to show the Supervisor Name:

Manager Name = CALCULATE( MAX('Table'[Employee]) , 'Table'[Role]="Supervisor")

vyueyunzhmsft_0-1678672623220.png

(2)If you want to create a calcualted column in your table , you can use this dax code:

Column = var _cur_manager =[Manager]
var _sum = SUMX(FILTER('Table','Table'[Manager] = _cur_manager) , [Sales])
return
IF([Role]="Supervisor"  ,_sum ,[Sales])

 

vyueyunzhmsft_1-1678672665571.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @v-yueyunzh-msft,

 

Thank you for the reply and the solution, the calculated column worked. In my actual scenario I had to create a Summarized table and then add the calculated column but in all the issue has been resolved.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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