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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Renjith
Helper II
Helper II

Calculated Column Help

Friends

Could you please help me to update the below formula to acheive case 4 of below requirement.

Using this formula I have acheived till 3rd requirement

 

 

Formula

 

Baseline Variation =
var a = if(ISBLANK(Sheet1[Result]),0,Sheet1[Result])

var b = maxx(filter(Sheet1,Sheet1[ID]=EARLIER(Sheet1[ID]) && Sheet1[Flag]="Y"
&& Sheet1[Test]]=EARLIER(Sheet1[Test]])
&& Sheet1[Cat]=EARLIER(Sheet1[Cat]) ),Sheet1[Result])

var c =IF(ISBLANK(b),0,b-a)
return if(Sheet1[STATUS]="NOT DONE",BLANK(), c)

 

Requirement

 

Case 1 : ID having multiple rows and 1 row having Y value in Flag Field

ID    Test         Cat            Flag       STATUS            Result          Baseline Variation
1        A            C1                                                       5                       10
1        A             C1                                                    10                        5
1        A             C1             Y                                     15                        0
1        A              C1                                                    25                      10
1        A             C1                                                    35                        20

Case 2 : ID having single row and No Y value present in Flag Field, Set baseline as 0

ID                  Test              Cat                 Flag              STATUS        Result       Baseline Variation
2                      B                 C2                                                             5                               0

 

Case 3 : IDs have STATUS field value = NOT DONE, set baseline as blank

ID                  Test             Cat                  Flag            STATUS       Result        Baseline Variation
3                     C                 C3                                    NOT DONE

 

Case 4 : IDs have Result field value = blank, set baseline as blank

ID              Test             Cat           Flag              STATUS     Result                     Baseline Variation
4                   D              C4

 

 

2 REPLIES 2
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Renjith 


is your problem solved?
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Renjith ,

 

try this

 

 

Baseline Variation =
VAR a =
    IF ( ISBLANK ( Sheet1[Result] ), 0, Sheet1[Result] )
VAR b =
    MAXX (
        FILTER (
            Sheet1,
            Sheet1[ID] = EARLIER ( Sheet1[ID] )
                && Sheet1[Flag] = "Y"
                && Sheet1[Test] = EARLIER ( Sheet1[Test] )
                && Sheet1[Cat] = EARLIER ( Sheet1[Cat] )
        ),
        Sheet1[Result]
    )
VAR c =
    IF ( ISBLANK ( b ), 0, b - a )
RETURN
    IF ( Sheet1[STATUS] = "NOT DONE" || ISBLANK ( Sheet1[Result] ), BLANK (), c )

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.