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
pbibmac_08
New Member

How to include multiple years in SUMX function

Hey PBI Community - I am trying to write a query to sum up the life-to-date financials. This would mean filtering for several different fiscal years. I have tried with the query below but when I create this measure and drag it in to the PBI workspace nothing comes up. Any recommendations would be very much appreciated! 

 

LTD Actuals =

var FSG = SELECTEDVALUE('Trended PL'[FSG5])

var a =

    SUMX(

        FILTER('Trended PL',

        'Trended PL'[Scenario]="Actual"

         &&'Trended PL'[Fiscal Year]="FY2019"

         &&'Trended PL'[Fiscal Year]="FY2020"),

          'Trended PL'[PL Amount CYP])

return  IF(FSG="FSG10000",a,a*-1)

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below whether it suits your requirement.

 

LTD Actuals =
VAR FSG =
    SELECTEDVALUE ( 'Trended PL'[FSG5] )
VAR a =
    SUMX (
        FILTER (
            'Trended PL',
            'Trended PL'[Scenario] = "Actual"
                && OR (
                    'Trended PL'[Fiscal Year] = "FY2019",
                    'Trended PL'[Fiscal Year] = "FY2020"
                )
        ),
        'Trended PL'[PL Amount CYP]
    )
RETURN
    IF ( FSG = "FSG10000", a, a * -1 )

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.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Ahmedx
Super User
Super User

I think you need this

LTD Actuals =
VAR FSG =
    SELECTEDVALUE ( 'Trended PL'[FSG5] )
VAR a =
    SUMX (
        FILTER (
            'Trended PL',
            'Trended PL'[Scenario] = "Actual"
                && 'Trended PL'[Fiscal Year] in {"FY2019","FY2020"}
        ),
        'Trended PL'[PL Amount CYP]
    )
RETURN
    IF ( FSG = "FSG10000", a, a * -1 )

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below whether it suits your requirement.

 

LTD Actuals =
VAR FSG =
    SELECTEDVALUE ( 'Trended PL'[FSG5] )
VAR a =
    SUMX (
        FILTER (
            'Trended PL',
            'Trended PL'[Scenario] = "Actual"
                && OR (
                    'Trended PL'[Fiscal Year] = "FY2019",
                    'Trended PL'[Fiscal Year] = "FY2020"
                )
        ),
        'Trended PL'[PL Amount CYP]
    )
RETURN
    IF ( FSG = "FSG10000", a, a * -1 )

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.


Go to My LinkedIn Page


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.