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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

New column to get complementary row data if multiple criteria is met

Hi,

I want to create a new column within the same table based in 3 criterias&columns that must be met:
-Same Code
-Same Month
-Same Prov.
If they are equal, then the new column will contain the missing data between another 2 columns: Amount and Fact.

Example Table:

CodeMonthProv.AmountFact.
474588221A10000
474588221A05
474522661B50000
1234562C2000
1234562C01


We add the new column and get:

CodeMonthProv.AmountFact.NewColumn
474588221A100005
474588221A051000
474522661B500000
1234562C20001
1234562C01200


Thanks!!

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Anonymous  try this as a new column

 

X = 
IF (
    [Fact.] = 0
        && CALCULATE (
            MAX ( tx[Fact.] ),
            ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
        ) <> 0,
    CALCULATE (
        MAX ( tx[Fact.] ),
        ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
    ),
    IF (
        [Amount] = 0
            && CALCULATE (
                MAX ( tx[Fact.] ),
                ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
            ) <> 0,
        CALCULATE (
            MAX ( tx[Amount] ),
            ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
        )
    )
)

 

breakdown with three 3 calculated columns

_maxfact = CALCULATE(MAX(tx[Fact.]),ALLEXCEPT(tx,tx[Code],tx[Month],tx[Prov.]))

_maxamt = CALCULATE(MAX(tx[Amount]),ALLEXCEPT(tx,tx[Code],tx[Month],tx[Prov.]))

New Column = Column = IF([Fact.]=0&&[_maxfact]<>0,[_maxfact], IF([Amount]=0&&[_maxfact]<>0,[_maxamt]))

 

Capture.PNG

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

2 REPLIES 2
smpa01
Super User
Super User

@Anonymous  try this as a new column

 

X = 
IF (
    [Fact.] = 0
        && CALCULATE (
            MAX ( tx[Fact.] ),
            ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
        ) <> 0,
    CALCULATE (
        MAX ( tx[Fact.] ),
        ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
    ),
    IF (
        [Amount] = 0
            && CALCULATE (
                MAX ( tx[Fact.] ),
                ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
            ) <> 0,
        CALCULATE (
            MAX ( tx[Amount] ),
            ALLEXCEPT ( tx, tx[Code], tx[Month], tx[Prov.] )
        )
    )
)

 

breakdown with three 3 calculated columns

_maxfact = CALCULATE(MAX(tx[Fact.]),ALLEXCEPT(tx,tx[Code],tx[Month],tx[Prov.]))

_maxamt = CALCULATE(MAX(tx[Amount]),ALLEXCEPT(tx,tx[Code],tx[Month],tx[Prov.]))

New Column = Column = IF([Fact.]=0&&[_maxfact]<>0,[_maxfact], IF([Amount]=0&&[_maxfact]<>0,[_maxamt]))

 

Capture.PNG

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Amazing answer!!

Thanks a lot!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors