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! Request now

Reply
kumsha1
Post Patron
Post Patron

replaces the values of same columns on conditions from same and other column

Hi,

Can someone help me with the DAX for below. TIA.

Current format

kumsha1_0-1652241940919.png

Required format

If Att=Running Hours and Values=0 then (Values=0 where Att=Throughput)

10 REPLIES 10
TheoC
Super User
Super User

Hi @kumsha1 

 

What is the output you hope to see from the calculation?

 

Thanks,
Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Hi @TheoC 

If Att=Running Hours and Values=0 then i want to make the Throughput values 0 as below

 

AttValues
Running Hours0
Throughput0.00

There could be other Att in the table, so i just want to make the values 0 where Att=Throughput

Hi @kumsha1 

 

You can use a calculated column like this:

 

_Value = 

VAR _1 = "Running Hours"
VAR _2 = "Throughput"
VAR _3 = SWITCH ( TRUE () , 'Table'[Att] = _1 && 'Table'[Values] = 0 , 'Table'[Values] )
VAR _4 = SWITCH ( TRUE () , _3 = 0 && 'Table'[Att] = _2 , 0 , 'Table'[Values] )

RETURN

_4

Output is like below:

 

TheoC_0-1652245443873.png

 

PBIX also attached for further help 🙂

 

In the example above, I hadded a few other "Att" items just to show you that the calculated column only picks up the Running Hours that are 0 and then creates the Throughput to be 0 as well, as required.

 

All the best!

Theo 

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Hi @TheoC , this seems to be working for distinct individual Att values but not for duplicate values as mentioned below. TIA

 

kumsha1_0-1652254887500.png

 

@kumsha1 can you please provide all of the data in the exact state that it is in that you are working with?  It seems as though there is missing data and each attempt at providing a solution brings new information. To ensure that @Anonymous and I can assist you, can you please provide sample data that matches the exact data in your Power BI file.  @Anonymous has provided some really great solutions and I am a bit surprised that these are not working for you, hence the need to see the sample data or alternatively get a copy of your PBIX file.  

 

Thank you in advance for your understanding.

 

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Hi @kumsha1 ,

 

I think TheoC's code will let all "Throughput" value return 0 if there is one "Running Hours" value equal to 0. So you will get result as the above screenshot. Accroding to your screenshot, I know there should be the same number of "Throughput" and "Running Hours". Is there a one-to-one correspondence between them? So you want one of "Throughput" returns 0 and other three return the original values. If they are one-to-one, then there should be a column like [Index] to determind this.

Table should look like as below.

RicoZhou_0-1652422793883.png

If there is not a column like [Index] in your table, you can add it by yourself in Power Query Editor.

For reference:

Create Row Number for Each Group in Power BI using Power Query

Try this code.

New Value =
VAR _Value_Att =
    CALCULATE (
        SUM ( 'Table'[Values] ),
        FILTER (
            'Table',
            'Table'[Index] = EARLIER ( 'Table'[Index] )
                && 'Table'[Attribute] = "Running Hours"
        )
    )
RETURN
    SWITCH (
        'Table'[Attribute],
        "Throughput", IF ( _Value_Att = 0, 0, 'Table'[Values] ),
        'Table'[Values]
    )

Result is as below.

RicoZhou_1-1652423546178.png

 

Best Regards,
Rico Zhou

 

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

 

 

Hi @Anonymous , thanks for your reply.

 

Below is my data. Attributes can be showed together or individually on different tables and they also have table level filters applied. In either case i  want to show Througput value as 0 when the Attribute=Running Hours and Values=0. I am quite not sure if ReportElement can be used to make 1-1 relationship..TIA

 

kumsha1_0-1652841941867.png

 

Anonymous
Not applicable

Hi @kumsha1 ,

 

I think you can try this code to create a measure to achieve your goal.

New Value = 
VAR _Value =
    CALCULATE ( SUM ( 'Table'[Values] ) )
VAR _Value_Att =
    CALCULATE (
        SUM ( 'Table'[Values] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[ReportElement] ),
            'Table'[Attribute] = "Running Hours"
        )
    )
RETURN
    SWITCH (
        MAX ( 'Table'[Attribute] ),
        "Throughput", IF ( _Value_Att = 0, 0, _Value ),
        _Value
    )

Result is as below.

RicoZhou_0-1652858548521.png

 

Best Regards,
Rico Zhou

 

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

Thanks again @Anonymous , above solution is not working for me and i think it works only if we have two attributes since MAX was used in RETURN statement, there could be many other attributes with different table filters. I really need a solution that works in any scenario. I am also trying if we can do this by another duplicate table but not sure if it works, if you come across any other solutions pls let me know here. cheers 

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