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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to create measure that will check if there is decrease or increase in value based on date

Hello, 

I want to create measure/column that will check if values are going up or down. 

I have three columns (ID,date,value)
Matrix example.

nemp_0-1648468623421.png


Here is the what I want 

If decrease in value is up to 150, I want result to be = 1
If decrease in value is over 150, I want result to be = 2
If increase in value is up to 100, I want result to be = 3

If increase in value is over 100, I want result to be = 4

I am not sure how I am suppose to calculate values between previous dates, every comment is helpful. 
Thanks a lot!





1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture2.png

 

Value measure: = 
SUM( Data[Value] )

 

Flag measure: =
VAR currentvalue = [Value measure:]
VAR previousvalue =
    CALCULATE ( [Value measure:], 'Calendar'[Date] = MAX ( 'Calendar'[Date] ) - 1 )
VAR comparisonvalue = currentvalue - previousvalue
RETURN
    IF (
        currentvalue <> BLANK ()
            && previousvalue <> BLANK (),
        SWITCH (
            TRUE (),
            comparisonvalue < -150, 2,
            comparisonvalue >= -150
                && comparisonvalue < 0, 1,
            comparisonvalue >= 0
                && comparisonvalue <= 100, 3,
            comparisonvalue > 100, 4
        )
    )

 

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks a lot for all your comments!

All three solutions are good, but I prefered the one I accepted.

Best nemp 

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this:-

Column = 
var PreviousDate = MAXX(FILTER(ALL('Table (2)'),EARLIER([Date]) > [Date] ),[Date])
var previousValue = CALCULATE(MAX([value]),FILTER('Table (2)',[Date] = PreviousDate))
var change = if(previousValue <> blank(),previousValue - [value],[value])
Return SWITCH(TRUE(),
previousValue <> blank() && change <= -150,1,
previousValue <> blank() && change > -150,2,
previousValue <> blank() && change <100,3,
previousValue <> blank() && change >100,4)

 

Output:-

Samarth_18_0-1648470029729.png

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture2.png

 

Value measure: = 
SUM( Data[Value] )

 

Flag measure: =
VAR currentvalue = [Value measure:]
VAR previousvalue =
    CALCULATE ( [Value measure:], 'Calendar'[Date] = MAX ( 'Calendar'[Date] ) - 1 )
VAR comparisonvalue = currentvalue - previousvalue
RETURN
    IF (
        currentvalue <> BLANK ()
            && previousvalue <> BLANK (),
        SWITCH (
            TRUE (),
            comparisonvalue < -150, 2,
            comparisonvalue >= -150
                && comparisonvalue < 0, 1,
            comparisonvalue >= 0
                && comparisonvalue <= 100, 3,
            comparisonvalue > 100, 4
        )
    )

 

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@Anonymous . With help from date table joined with date of your table have measures like

 

This Day = CALCULATE(sum('Table'[value]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('Table'[value]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))

diff =[This Day] - [Last Day]

 

Then create a measure like

Switch( True(),

[diff] <-150 ,2 ,

[diff] <0 , 1 ,

[diff] <100 , 3 ,

4)

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.