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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jwin2424
Resolver I
Resolver I

Filter a calculation based on custom year

I am trying to wrap my head around this, but I cannot get this right. I have custom dates, so time intellgence models don't work. Example, ONLY January 3rd - Jan 20th falls within January. Anytime I use time intellegence, it uses a calendar year. 

 

I have a calculation that results in a % value, and I simply want a formula that shows me the prior year's %. It seems like no matter HOW I filter, I keep getting the current year. Here is the last code I tried:

Conversion Rate YoY = 
VAR _LeadCount = Calculate(COUNT(Leads[Lead ID]), Leads[Qualification Group]="Partner Qualification", NOT(ISBLANK('Company Leads Report'[Status])))
VAR _WonCount = CALCULATE(COUNT('Leads'[Lead ID]),'Company Leads Report'[Status]="Closed - Won", Leads[Qualification Group]="Partner Qualification")
VAR _CurrentYR= DIVIDE(_WonCount, _LeadCount)

RETURN
    CALCULATE(
        _CurrentYR
        , 'Fiscal Calendar'[Year] = 'Fiscal Calendar'[Year] - 1
        )

 

Here is what it returns:

jwin2424_0-1659121187801.png

 

I have even tried other filter expressions, but it keeps giving me the current year. I don't know where I am going wrong. 

 

Thanks! 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @jwin2424 
Please try

Conversion Rate YoY =
VAR _LeadCount =
    CALCULATE (
        COUNT ( Leads[Lead ID] ),
        Leads[Qualification Group] = "Partner Qualification",
        NOT ( ISBLANK ( 'Company Leads Report'[Status] ) ),
        'Fiscal Calendar'[Year]
            = MAX ( 'Fiscal Calendar'[Year] ) - 1
    )
VAR _WonCount =
    CALCULATE (
        COUNT ( 'Leads'[Lead ID] ),
        'Company Leads Report'[Status] = "Closed - Won",
        Leads[Qualification Group] = "Partner Qualification",
        'Fiscal Calendar'[Year]
            = MAX ( 'Fiscal Calendar'[Year] ) - 1
    )
VAR _CurrentYR =
    DIVIDE ( _WonCount, _LeadCount )
RETURN
    _CurrentYR

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @jwin2424 
Please try

Conversion Rate YoY =
VAR _LeadCount =
    CALCULATE (
        COUNT ( Leads[Lead ID] ),
        Leads[Qualification Group] = "Partner Qualification",
        NOT ( ISBLANK ( 'Company Leads Report'[Status] ) ),
        'Fiscal Calendar'[Year]
            = MAX ( 'Fiscal Calendar'[Year] ) - 1
    )
VAR _WonCount =
    CALCULATE (
        COUNT ( 'Leads'[Lead ID] ),
        'Company Leads Report'[Status] = "Closed - Won",
        Leads[Qualification Group] = "Partner Qualification",
        'Fiscal Calendar'[Year]
            = MAX ( 'Fiscal Calendar'[Year] ) - 1
    )
VAR _CurrentYR =
    DIVIDE ( _WonCount, _LeadCount )
RETURN
    _CurrentYR

This worked. 

I see MAX used a lot when determining this. I was wondering if maybe you could elaborate on why it was needed? 

 

Thank you again!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.