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

IF function comparing values in same column

Hi!

 

I have this set of data:

 

Udklip2.PNGUdklip3.PNG

 

I want to make a IF-function that tells me if there is a variation in the rows in column 'Blyfri95' or 'Diesel' between ex. 28-02-2019 and 01-03-2019, and if there is one i want it to give me the value 1 and if not i want the value 0 in the 28-02-2019 row.

 

So in the row 28-02-2019 i want the value 1 in the 'Variation' column because we see a variation in 'Blyfri95' to the next day.

 

I have tried the formula 

Variation = IF(Priser[Blyfri95] = Priser[Blyfri95];0;1)
1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

 

Please create an index column in query editor firstly and then create a calculated column with the formula below.

 

Column =
VAR a =
    CALCULATE (
        MAX ( 'Table1'[Blyfri95] ),
        FILTER ( 'Table1', 'Table1'[Index] = EARLIER ( Table1[Index] ) - 1 )
    )
RETURN
    IF ( ISBLANK ( a ), BLANK (), IF ( a <> 'Table1'[Blyfri95], 1, 0 ) )

Here is my test output.

 

Capture.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

1 REPLY 1
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

 

Please create an index column in query editor firstly and then create a calculated column with the formula below.

 

Column =
VAR a =
    CALCULATE (
        MAX ( 'Table1'[Blyfri95] ),
        FILTER ( 'Table1', 'Table1'[Index] = EARLIER ( Table1[Index] ) - 1 )
    )
RETURN
    IF ( ISBLANK ( a ), BLANK (), IF ( a <> 'Table1'[Blyfri95], 1, 0 ) )

Here is my test output.

 

Capture.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.