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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
HenryJS
Post Prodigy
Post Prodigy

New Column: If Statement

Hi all,

 

I want to create a new column. I have two tables - please see below.

 

The query required is:

  • IF 'Export Candidates'[CandidatePayType] = "Umbrella" or "Ltd"
  • THEN ('Export Placements'[Rate1ChargeRate] - 'Export Placements'Rate1PayRate')
  • *5 IF 'Export Placements'[HourlyOrShiftRate] = "per day"
  • *40 IF 'Export Placements'[HourlyOrShiftRate] = "per hour"

 

Hope that makes sense. Please ask if further details required.

 

Export Placements

CandidateNameHourlyOrShiftRateRate1PayRateRate1ChargeRate
Johnper day195235
Maxper day250287.5
Tomper day200240
Ianper day200230
Jerryper hour160219.5
Andrewper hour195229
Philper hour185219.5

 

 

Export Candidates

 

CandidateNameCandidatePayType
JohnPAYE
MaxLtd
TomUmbrella
IanLtd
JerryUmbrella
AndrewUmbrella
PhilLtd

 

 

Cheers

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

Hi  @HenryJS .

 

1. Create a relationship between the 2 tables:

Annotation 2020-04-14 175205.png

2.Create a measure as below:

 

Measure = 
var a=MAX('Export Placements'[Rate1ChargeRate])-MAX('Export Placements'[Rate1PayRate])
Return
IF(SELECTEDVALUE('Export Candidates'[CandidatePayType])="Umbrella" || SELECTEDVALUE('Export Candidates'[CandidatePayType])="Ltd",a,
IF(SELECTEDVALUE('Export Placements'[HourlyOrShiftRate])="per day",a*5,
IF(SELECTEDVALUE('Export Placements'[HourlyOrShiftRate])="per hour",a*40,BLANK())))

 

Finally you will see:

Annotation 2020-04-14 175351.png

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

6 REPLIES 6
v-kelly-msft
Community Support
Community Support

Hi  @HenryJS .

 

1. Create a relationship between the 2 tables:

Annotation 2020-04-14 175205.png

2.Create a measure as below:

 

Measure = 
var a=MAX('Export Placements'[Rate1ChargeRate])-MAX('Export Placements'[Rate1PayRate])
Return
IF(SELECTEDVALUE('Export Candidates'[CandidatePayType])="Umbrella" || SELECTEDVALUE('Export Candidates'[CandidatePayType])="Ltd",a,
IF(SELECTEDVALUE('Export Placements'[HourlyOrShiftRate])="per day",a*5,
IF(SELECTEDVALUE('Export Placements'[HourlyOrShiftRate])="per hour",a*40,BLANK())))

 

Finally you will see:

Annotation 2020-04-14 175351.png

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Hi @v-qiuyu-msft 

 

Could you kindly explain why you have chosen the solution that you have as solving the OP's question please? It seems that there are other posts that provide solutions more in line with the OP's requirements and display outcomes as the OP described. The solution accepted does not appear to show the desired output.

 

Thanks.



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Pragati11
Super User
Super User

Hi @HenryJS ,

 

Have you got any relationship in place between these 2 tables?

Also, your last 2 conditions don't have an outcome against it as highlighted below:

  • IF 'Export Candidates'[CandidatePayType] = "Umbrella" or "Ltd"
  • THEN ('Export Placements'[Rate1ChargeRate] - 'Export Placements'Rate1PayRate')
  • *5 IF 'Export Placements'[HourlyOrShiftRate] = "per day"
  • *40 IF 'Export Placements'[HourlyOrShiftRate] = "per hour"

Also, what does *5 and *40 signify here?

 

Thanks,

Pragati

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi @Pragati11 

 

*5 and * 40 signify x 5 and x 40 respectively

 

So,

 

IF 'Export Placements'[HourlyOrShiftRate] = "per day"

THEN ('Export Placements'[Rate1ChargeRate] - 'Export Placements'Rate1PayRate') *5

 

and 

IF 'Export Placements'[HourlyOrShiftRate] = "per hour"

THEN ('Export Placements'[Rate1ChargeRate] - 'Export Placements'Rate1PayRate') *40

 

Hi @HenryJS ,

 

I am assuming following:

  1. You have got a relationship in place between these 2 tables.
  2. 'Export Placements'[HourlyOrShiftRate] has only 2 unique values"per day" and "per hour"

 

Based on the above assumptions, You can create a column using following DAX expression:

Calc_Column = IF (

                             'Export Candidates'[CandidatePayType] = "Umbrella" ||  'Export Candidates'[CandidatePayType] = "Ltd", 

                             'Export Placements'[Rate1ChargeRate] - 'Export Placements'Rate1PayRate',

                              IF('Export Placements'[HourlyOrShiftRate] = "per day",

                                  ('Export Placements'[Rate1ChargeRate] - 'Export Placements'Rate1PayRate') *5,

                                  ('Export Placements'[Rate1ChargeRate] - 'Export Placements'Rate1PayRate') *40

                                 )

                            )

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi @HenryJS 

 

Please try this measure (assuming relationship between the two tables - the data you provided gives 1:1 relationship on name):

_measure = 
VAR paytype =
    MAX(ExportCandidates[CandidatePayType])
VAR shifttype =
    MAX(ExportPlacements[HourlyOrShiftRate])
RETURN
    IF(
        paytype = "Umbrella" || paytype = "Ltd",
        SUMX(
            ExportPlacements,
            ExportPlacements[Rate1ChargeRate] - ExportPlacements[Rate1PayRate]
        ) *
        SWITCH(
            TRUE(),
            shifttype = "per day", 5,
            shifttype = "per hour", 40
        ),
        0
    )

 

This gives me the following results:

HensryJS_IF.PNG

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.