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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
PBInewbie17
Helper I
Helper I

Filter Multiple Criteria

Hi, all. I have the following table with multiple projects.

PBInewbie17_0-1666209245818.png

I need a new column called Fiscal Year that is calculated based on the following criteria: 

  1. Must be the MAX Sequence for the project
  2. Must be an an Action_Name of either “Returned app” or “Completed app”
  • If the two criteria above apply and the Action_Date is 10/01/2020 – 09/30/2021, then Fiscal Year = “FY21”
  • If the first two criteria apply and the Action_Date is 10/01/2021 – 09/30/2022, then Fiscal Year = “FY22”
  • If the first two criteria apply and the Action_Date is 10/01/2022 – 09/30/2023, then Fiscal Year = “FY23”
  • If nothing applies, then BLANK
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@PBInewbie17 Try:

FY Column =
  VAR __Seq = [Sequence]
  VAR __Project = [Project]
  VAR __Action = [Action_Name]
  VAR __Table = FILTER('Table',[Project] = __Project)
  VAR __MaxSeq = MAXX(__Table,[Sequence])
RETURN
  IF(
    __Seq = __MaxSeq && ( __Action = "Returned app" || __Action = "Completed app" ),
    SWITCH(TRUE(),
      [Action_Date] >= DATE(2020,10,1) && [Action_Date] <= DATE(2021,9,30),"FY21",
      [Action_Date] >= DATE(2021,10,1) && [Action_Date] <= DATE(2022,9,30),"FY21",      
      [Action_Date] >= DATE(2022,10,1) && [Action_Date] <= DATE(2023,9,30),"FY21",
      BLANK()
    ),
    BLANK()
  )

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@PBInewbie17 Try:

FY Column =
  VAR __Seq = [Sequence]
  VAR __Project = [Project]
  VAR __Action = [Action_Name]
  VAR __Table = FILTER('Table',[Project] = __Project)
  VAR __MaxSeq = MAXX(__Table,[Sequence])
RETURN
  IF(
    __Seq = __MaxSeq && ( __Action = "Returned app" || __Action = "Completed app" ),
    SWITCH(TRUE(),
      [Action_Date] >= DATE(2020,10,1) && [Action_Date] <= DATE(2021,9,30),"FY21",
      [Action_Date] >= DATE(2021,10,1) && [Action_Date] <= DATE(2022,9,30),"FY21",      
      [Action_Date] >= DATE(2022,10,1) && [Action_Date] <= DATE(2023,9,30),"FY21",
      BLANK()
    ),
    BLANK()
  )

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you, Greg. One other caveat: I have another column called Days_between_Actions that is used to calculate the total number of days to complete a project (e.g., Project A took 24 days to complete [13 + 11 = 24]). The formula below is excluding certain days from the calculation. For example, it's showing Project A as 11 days instead of the correct 24. How can I adjust the formula to ensure the Days_between_Actions column isn't affected?

PBInewbie17_1-1666220837010.png

FY Column =
VAR __Seq = [Sequence]
VAR __Project = [Project]
VAR __Action = [Action_Name]
VAR __Table =
    FILTER ( 'Table', [Project] = __Project )
VAR __MaxSeq =
    MAXX ( __Table, [Sequence] )
RETURN
    IF (
        __Seq = __MaxSeq
            && ( __Action = "Returned app"
            || __Action = "Completed app" ),
        SWITCH (
            TRUE (),
            [Action_Date] >= DATE ( 2020, 10, 1 )
                && [Action_Date] <= DATE ( 2021, 9, 30 ), "FY21",
            [Action_Date] >= DATE ( 2021, 10, 1 )
                && [Action_Date] <= DATE ( 2022, 9, 30 ), "FY22",
            [Action_Date] >= DATE ( 2022, 10, 1 )
                && [Action_Date] <= DATE ( 2023, 9, 30 ), "FY23",
            BLANK ()
        ),
        BLANK ()
    )

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.