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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Trying to substract the values based on one column to another column

Hey,

 

I am trying to substract the values based on one column to another column.

 

In the below table ID is having groups of Data,if the ID and the Cycle No is 1,and the faults are different the output should be 1.


If the Same ID and Cycle No are different faults are same then the output suould be substract with the same Cycle No (For Example ID:K09031 Cycle No:2 Fault: No then next Cycle No:6 same Fault: No then output should be 6-2=4 & ID:K09031 Cycle No:2 Fault: No then next Cycle No:8 same Fault: No then output should be 8-2=6)


If the Same ID and Cycle No are different faults are same then the output suould be substract with the same Cycle No (For Example ID:K11121 Cycle No:1 Fault: Damage then next Cycle No:3 same Fault: Damage then output should be 3-1=2 , ID:K11121 Cycle No:1 Fault: Damage then next Cycle No:5 same Fault: Damage then output should be 5-1=4, ID:K11121 Cycle No:1 Fault: Damage then next Cycle No:6 same Fault: Damage then output should be 6-1=5, ID:K11121 Cycle No:3 Fault: No then next Cycle No:6 same Fault: No then output should be 6-3=3 & ID:K11121 Cycle No:1 Fault: Edge then next Cycle No:6 same Fault: Edge then output should be 6-1=5)


Note: Here Id has indusival groups with cycle no's and different faults, that should substract with the same fault occurs in the same group with earlier cycle no has same fault occur.

 

An Example if my dataset is this with required Solution Column:

 

IdCycle NoFaultSolution Column
KL00021Edge1
KL00021Damage1
K090312Edge2
K090312No2
K090316No4
K090318With8
K090318No6
K111211Damage1
K111211Edge1
K111213No3
K111213Damage2
K111215Damage4
K111216With6
K111216Damage5
K111216No3
K111216Edge5
KG13661No1
KG55601With1
H152385Edge5
H156781No1
HG12341No1
HG12341Edge1
H085422With2

 

Anyone with some ideas on how to fix this? Manually is not an option as there are thousands of datapoints.

 

Thanks & Regards,

Dharani

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Picture1.png

 

Solution column CC =
VAR mincyclenumber =
    MINX (
        FILTER (
            Data,
            Data[Id] = EARLIER ( Data[Id] )
                && Data[Fault] = EARLIER ( Data[Fault] )
        ),
        Data[Cycle No]
    )
RETURN
    SWITCH (
        TRUE (),
        Data[Cycle No] = mincyclenumber, mincyclenumber,
        Data[Cycle No] - mincyclenumber
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

Hi,

Thank you for your message, and please check the attached file.

 

Solution column V2 CC =
VAR currentcyclenumber = Data[Cycle No]
VAR mincyclenumber =
    MINX (
        FILTER (
            Data,
            Data[Id] = EARLIER ( Data[Id] )
                && Data[Fault] = EARLIER ( Data[Fault] )
        ),
        Data[Cycle No]
    )
VAR maxcyclenumber_beforecurrent =
    MAXX (
        FILTER (
            Data,
            Data[Id] = EARLIER ( Data[Id] )
                && Data[Fault] = EARLIER ( Data[Fault] )
                && Data[Cycle No] < currentcyclenumber
        ),
        Data[Cycle No]
    )
RETURN
    SWITCH (
        TRUE (),
        Data[Cycle No] = mincyclenumber, mincyclenumber,
        Data[Cycle No] - maxcyclenumber_beforecurrent
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Picture1.png

 

Solution column CC =
VAR mincyclenumber =
    MINX (
        FILTER (
            Data,
            Data[Id] = EARLIER ( Data[Id] )
                && Data[Fault] = EARLIER ( Data[Fault] )
        ),
        Data[Cycle No]
    )
RETURN
    SWITCH (
        TRUE (),
        Data[Cycle No] = mincyclenumber, mincyclenumber,
        Data[Cycle No] - mincyclenumber
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Thanks Kim Great Work.

 

Need one more help,

 

IdCycle NoFaultSolution Column
KL00021Edge1
KL00021Damage1
K090312Edge2
K090312No2
K090316No4
K090318With8
K090318No2
K111211Damage1
K111211Edge1
K111213No3
K111213Damage2
K111215Damage2
K111216With6
K111216Damage1
K111216No3
K111216Edge5
KG13661No1
KG55601With1
H152385Edge5
H156781No1
HG12341No1
HG12341Edge1
H085422With2

 

If the Same ID and Cycle No are different faults are same then the output suould be substract with the same Cycle No (For Example ID:K09031 Cycle No:2 Fault: No then next Cycle No:6 same Fault: No then output should be 6-2=4 & ID:K09031 Cycle No:6 Fault: No then next Cycle No:8 same Fault: No then output should be 8-6=2)


If the Same ID and Cycle No are different faults are same then the output suould be substract with the same Cycle No (For Example ID:K11121 Cycle No:1 Fault: Damage then next Cycle No:3 same Fault: Damage then output should be 3-1=2 , ID:K11121 Cycle No:3 Fault: Damage then next Cycle No:5 same Fault: Damage then output should be 5-3=2, ID:K11121 Cycle No:5 Fault: Damage then next Cycle No:6 same Fault: Damage then output should be 6-5=1, ID:K11121 Cycle No:3 Fault: No then next Cycle No:6 same Fault: No then output should be 6-3=3 & ID:K11121 Cycle No:1 Fault: Edge then next Cycle No:6 same Fault: Edge then output should be 6-1=5)

 

 

I mean that in the earlier fault place need recent fault occurence in the recent Cycle Count

 

Thanks,

Dharani

Hi,

Thank you for your message, and please check the attached file.

 

Solution column V2 CC =
VAR currentcyclenumber = Data[Cycle No]
VAR mincyclenumber =
    MINX (
        FILTER (
            Data,
            Data[Id] = EARLIER ( Data[Id] )
                && Data[Fault] = EARLIER ( Data[Fault] )
        ),
        Data[Cycle No]
    )
VAR maxcyclenumber_beforecurrent =
    MAXX (
        FILTER (
            Data,
            Data[Id] = EARLIER ( Data[Id] )
                && Data[Fault] = EARLIER ( Data[Fault] )
                && Data[Cycle No] < currentcyclenumber
        ),
        Data[Cycle No]
    )
RETURN
    SWITCH (
        TRUE (),
        Data[Cycle No] = mincyclenumber, mincyclenumber,
        Data[Cycle No] - maxcyclenumber_beforecurrent
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Hi Kim,

 

Need your help, if possible please help me.

 

Need help here to get solution of "Rank based on Serial No, Cycle Count & Fault Type" & "Rank based on serial No, Log Date and Fault Type". With calculated column(DAX) or Power Query is fine.

 

 

Rank based on Serial No, Cycle Count & Fault Type = Count of distinct Cycles when similar fault Type Occur

Rank based on serial No, Log Date and Fault Type = Count of distinct last different log Date when similar fault type logged

 

Fault TypeSerial NoCycle CountLog DateRank based on Serial No, Cycle Count & Fault TypeRank based on Serial No, Log Date & Fault Type
BentS1256210-Aug-2111
Ink FailureS1256410-Sep-2111
Self StrippingS1256831-Dec-2111
BentS1256831-Dec-2122
Ink FailureS12561023-Feb-2222
BentS12561023-Feb-2233
Broken WeldS12561023-Feb-2211
Self StrippingS12561023-Feb-2222
Broken WeldS12561026-Feb-2212
Ink FailureS12561026-Feb-2223
Self StrippingS12561026-Feb-2223
BentS12561026-Feb-2234
Not PaintedS12561026-Feb-2211
Ink FailureS12561026-Feb-2223
BentS12561320-Apr-2245
Require StrippingS12561325-Apr-2211
Not PaintedS12561325-Apr-2222
Ink FailureM083117-Jan-2211
Ink FailureM083117-Jan-2211
BentM083117-Jan-2211
BentM083117-Jan-2211
Not PaintedM083117-Jan-2211
Not PaintedM083117-Jan-2211
Ink FailureM08333-Mar-2222
Ink FailureA863111-Oct-2111
Broken WeldA863111-Oct-2111
Self StrippingA863111-Oct-2111
Ink FailureA863114-Oct-2112
BentA863114-Oct-2111
Ink FailureA863114-Oct-2112

 

If you don't understand my communication regards this solution appoligies for that and please raise a question for clarification.

In Advance Thanks.

 

 

 

Thanks,

Dharani

 

Anonymous
Not applicable

Thanks a Ton Kim

This helps me alot

 

Thanks,

Dharani

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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