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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Correcting specific data values from an imported corrections table

Hey,

 

I have a dataset which has errors in it, I'm unable to get them corrected by the owner of the data so I want to correct the errors each time it is loaded from the source by taking values from a correction table and leave the rest from the source unchanged.

 

I've tried merges, apending rows (but causes other issues when the source changes), etc.

 

Here is a simplified example of the source:

 

Inventory NumberProduct TypeMotor TypeFuel Type
INV-000123CarCombustionPetrol
INV-000456BoatElectricElectricity
INV-000789CycleManualPetrol
INV-000234TrailerTowedNone

 

Correction table with the values that need correcting:

 

Inventory NumberProduct TypeMotor TypeFuel Type
INV-000789  None
INV-000234  N/A

 

End result:

Inventory NumberProduct TypeMotor TypeFuel Type
INV-000123CarCombustionPetrol
INV-000456BoatElectricElectricity
INV-000789CycleManualPetrol
INV-000234TrailerTowedN/A

 

The data set is much larger than this but hopefully this is enough to demonstrate what I am trying to do...

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Anonymous 

@Nithinr has provided a scheme to you. I have the following additions. Based on your description, I use the following sample data:

sheet1 table:

vjianpengmsft_0-1710121602171.png

sheet2 table:

vjianpengmsft_1-1710121637188.png

The relationships between the tables are as follows:

vjianpengmsft_3-1710122628105.png

 

I did this by using the following DAX expression in measure:

 

correct type measure =
VAR _id =
    CALCULATE ( MAX ( Sheet1[Inventory Number] ) )
VAR _type =
    CALCULATE ( MAX ( 'Sheet1'[Fuel Type] ) )
VAR _id1 =
    CALCULATE ( MAX ( Sheet2[Inventory Number] ) )
VAR _type1 =
    CALCULATE ( MAX ( 'Sheet2'[Fuel Type] ) )
RETURN
    SWITCH ( TRUE (), _id = _id1, _type1, _id <> _id1, _type )

 

Use calculate to obtain the Inventory Number and Fuel Type of the current row. Use the switch to determine whether the Inventory Number exists in the correct table, if it exists, the Fuel Type is the value in the correct table, and if it does not exist, it is the value of the current table.

Here are the results:

vjianpengmsft_2-1710122587252.png

If you want to do this with calculated columns, here's a workaround:

 

Column =
VAR _id = 'Sheet1'[Inventory Number]
VAR _type = 'Sheet1'[Fuel Type]
RETURN
    SWITCH (
        TRUE (),
        _id = RELATED ( Sheet2[Inventory Number] ), RELATED ( Sheet2[Fuel Type] ),
        _id <> RELATED ( Sheet2[Inventory Number] ), 'Sheet1'[Fuel Type]
    )

 

The DAX execution result of the calculated column is as follows:

vjianpengmsft_4-1710122780260.png

I've provided the PBIX file for this time below, and it would be great if I could help you

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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
Anonymous
Not applicable

Hi, @Anonymous 

@Nithinr has provided a scheme to you. I have the following additions. Based on your description, I use the following sample data:

sheet1 table:

vjianpengmsft_0-1710121602171.png

sheet2 table:

vjianpengmsft_1-1710121637188.png

The relationships between the tables are as follows:

vjianpengmsft_3-1710122628105.png

 

I did this by using the following DAX expression in measure:

 

correct type measure =
VAR _id =
    CALCULATE ( MAX ( Sheet1[Inventory Number] ) )
VAR _type =
    CALCULATE ( MAX ( 'Sheet1'[Fuel Type] ) )
VAR _id1 =
    CALCULATE ( MAX ( Sheet2[Inventory Number] ) )
VAR _type1 =
    CALCULATE ( MAX ( 'Sheet2'[Fuel Type] ) )
RETURN
    SWITCH ( TRUE (), _id = _id1, _type1, _id <> _id1, _type )

 

Use calculate to obtain the Inventory Number and Fuel Type of the current row. Use the switch to determine whether the Inventory Number exists in the correct table, if it exists, the Fuel Type is the value in the correct table, and if it does not exist, it is the value of the current table.

Here are the results:

vjianpengmsft_2-1710122587252.png

If you want to do this with calculated columns, here's a workaround:

 

Column =
VAR _id = 'Sheet1'[Inventory Number]
VAR _type = 'Sheet1'[Fuel Type]
RETURN
    SWITCH (
        TRUE (),
        _id = RELATED ( Sheet2[Inventory Number] ), RELATED ( Sheet2[Fuel Type] ),
        _id <> RELATED ( Sheet2[Inventory Number] ), 'Sheet1'[Fuel Type]
    )

 

The DAX execution result of the calculated column is as follows:

vjianpengmsft_4-1710122780260.png

I've provided the PBIX file for this time below, and it would be great if I could help you

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

Nithinr
Resolver III
Resolver III

Create a relationship between your source and correction table

rel.png

 

 

Use the calculated column 

 

Corrected = IF(RELATED(correction[Inventory Number]) == BLANK(),original[Fuel Type],RELATED(correction[Fuel Type]))

 

 

Corrected = IF(RELATED(correction[Inventory Number]) == BLANK() || RELATED(correction[Fuel Type]) == "None" ,original[Fuel Type],RELATED(correction[Fuel Type]))

use this for fuel type, you can adjust formula as per your requirement, use any one of them from above

 

Screenshot 2024-03-08 173250.png

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.