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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Antmkjr
Post Patron
Post Patron

Check occurance of a value in previous month value

https://drive.google.com/file/d/14SNn2oaQ1m9H9hx1r0QCN0MDnCBei3Fo/view?usp=share_link

 

Antmkjr_0-1667475414728.png

In the above report, i need a measure where, IF Month LFL for any previous months is Non LFL , then the following months in the same year should also show Non LFL for that particular category

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Antmkjr 
Please refer to attached file with the solution

1.png

Measure = 
VAR CurrentMonth = MAX ( 'Date'[MonthOfYear] )
VAR CurrentYear = MAX ( 'Date'[Year] )
VAR T1 = CALCULATETABLE ( SUMMARIZE ( Sheet1, 'Date'[Year], 'Date'[MonthOfYear] ), REMOVEFILTERS ( ) ) 
VAR T2 = FILTER ( T1, [MonthOfYear] <= CurrentMonth && [Year] = CurrentYear )
VAR T3 = 
    SELECTCOLUMNS ( 
        T2, 
        "@SPLY", 
        CALCULATE ( [Month LFL], FILTER ( T2, [MonthOfYear] = EARLIER ( [MonthOfYear] ) ), ALL ( 'Date' ) ) 
    )
VAR Result = IF ( "Non LFL" IN T3, "Non LFL", "LFL" ) 
RETURN
    Result

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @Antmkjr 
Please refer to attached file with the solution

1.png

Measure = 
VAR CurrentMonth = MAX ( 'Date'[MonthOfYear] )
VAR CurrentYear = MAX ( 'Date'[Year] )
VAR T1 = CALCULATETABLE ( SUMMARIZE ( Sheet1, 'Date'[Year], 'Date'[MonthOfYear] ), REMOVEFILTERS ( ) ) 
VAR T2 = FILTER ( T1, [MonthOfYear] <= CurrentMonth && [Year] = CurrentYear )
VAR T3 = 
    SELECTCOLUMNS ( 
        T2, 
        "@SPLY", 
        CALCULATE ( [Month LFL], FILTER ( T2, [MonthOfYear] = EARLIER ( [MonthOfYear] ) ), ALL ( 'Date' ) ) 
    )
VAR Result = IF ( "Non LFL" IN T3, "Non LFL", "LFL" ) 
RETURN
    Result

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.