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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply

calculate column value

TABLE1
EMP NOCOMPONENTPAY
EM0001BASIC5000
EM0001HRA300
EM0001TRNSPORT500
EM0001AIR TICKET 
EM0002BASIC7000
EM0002HRA300
EM0002TRNSPORT500
EM0002AIR TICKET 

 

 TABLE2 
EMP NO SECTOR IDNO OF TICKET
EM0001SEC-0012
EM0002SEC-0021
EM0003SEC-0013

 

TABLE 3
SECTOR IDTICKET FAIR
SEC-0012500
SEC-0026000
SEC-0031500

 

I need to calculate air ticket amount based on no off ticket, like EM001 =PAY =2*2500 =5000   

EM002 = 1*6000

 

TABLE1
EMP NOCOMPONENTPAY
EM0001BASIC5000
EM0001HRA300
EM0001TRNSPORT500
EM0001AIR TICKET5000
EM0002BASIC7000
EM0002HRA300
EM0002TRNSPORT500
EM0002AIR TICKET6000
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Since it looks like you're trying to add values into the existing Table1, I recommend that you do this work in Query Editor as opposed to DAX.

 

I propose the following method:

  1. In QE, merge Table2 with Table3, join on Sector ID.
  2. Merge this new table with Table1, join on EMP NO.  Now you have access to the [Ticket Fare] and [Number of Ticket] columns
  3. Create a custom column with the following logic:
    1. if [PAY] = null then [Ticket Fare] * [Number of Tickets] else [PAY]
  4. Delete the original [PAY] column, and the columns that were brought in from the merge operations (they're no longer needed and will bloat your data model).
  5. Rename your custom column to [PAY], and you should be all set.

View solution in original post

@sohailstsindia

 

If you have above relationships, you can add a calculated column in Table1

 

Revised Pay =
IF (
    Table1[COMPONENT] = "Air Ticket",
    RELATED ( Table2[NO OF TICKET] ) * RELATED ( Table3[TICKET FAIR] ),
    Table1[PAY]
)

4501.png

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Since it looks like you're trying to add values into the existing Table1, I recommend that you do this work in Query Editor as opposed to DAX.

 

I propose the following method:

  1. In QE, merge Table2 with Table3, join on Sector ID.
  2. Merge this new table with Table1, join on EMP NO.  Now you have access to the [Ticket Fare] and [Number of Ticket] columns
  3. Create a custom column with the following logic:
    1. if [PAY] = null then [Ticket Fare] * [Number of Tickets] else [PAY]
  4. Delete the original [PAY] column, and the columns that were brought in from the merge operations (they're no longer needed and will bloat your data model).
  5. Rename your custom column to [PAY], and you should be all set.

@sohailstsindia

 

I believe the 3 tables would have a relationship like this.

 

4500.png

@sohailstsindia

 

If you have above relationships, you can add a calculated column in Table1

 

Revised Pay =
IF (
    Table1[COMPONENT] = "Air Ticket",
    RELATED ( Table2[NO OF TICKET] ) * RELATED ( Table3[TICKET FAIR] ),
    Table1[PAY]
)

4501.png

Thanks Zubair, Its worked.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors