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
joshua1990
Post Prodigy
Post Prodigy

Current Fiscal Month TRUE FALSE

Hello everyone!

 I would like to add a binaer column into my fiscal calendar to get a TRUE/FALSE, if the date is in the current fiscal month.
How would you do that?
The fiscal months have specific start- and end dates.
The following approach is not working:
 

"Current Fiscal Month", IF (
AND ( FiscMonth = MONTH ( TODAY () ), FiscYear = YEAR ( TODAY () ) ),
TRUE (),
FALSE ()

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@joshua1990  You can try using ADDCOLUMNS function like this.

Calendar = 
VAR BaseCalendar =
    CALENDAR ( DATE ( 2018, 12, 31 ), DATE ( 2022, 01, 03 ) )
VAR FiscalCalendar = 
    GENERATE (
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR IsWorkingDay =
            IF ( WEEKDAY ( BaseDate, 2 ) > 5, FALSE (), TRUE () )
        VAR WorkingDayFactor =
            IF ( IsWorkingDay = TRUE (), 0, 1 )
        VAR Year =
            YEAR ( BaseDate )
        VAR MonthNumber =
            MONTH ( BaseDate )
        VAR WeekNumber =
            WEEKNUM ( BaseDate ) 
        VAR FiscWeek =
            WEEKNUM ( BaseDate, 21 )
        VAR FiscWeekTxt =
            FORMAT(WEEKNUM ( BaseDate, 21 ), "00")
        
        VAR FiscYear =
            IF (
                FiscWeek < 5
                    && WeekNumber > 50,
                Year + 1,
                IF ( FiscWeek > 50 && WeekNumber < 5, Year - 1, Year )
            )
        RETURN
            ROW (
                "Year", Year,
                "Month Number", MonthNumber,
                "Month", FORMAT ( BaseDate, "mmmm" ),
                "Year Month", FORMAT ( BaseDate, "yyyy-mm" ),
                "Day of Week", FORMAT ( BaseDate, "dddd" ),
                "Day of Week Number", WEEKDAY ( BaseDate, 2 ),
                "Day of Week Short", FORMAT ( BaseDate, "ddd" ),
                "IsWorkingDay", IF ( IsWorkingDay = TRUE (), 1, 0 ),
                "Week", WeekNumber,
                "Year-Week", Year & "-" & WeekNumber,
                "Fisc Week", FiscWeek,
                "Fisc Year-WK", FiscYear & "-" & FiscWeekTxt
            )
    )
VAR RESULT = ADDCOLUMNS
                    (
                    FiscalCalendar
                    , "IsCurrentFiscalMonth"
                    , VAR td = TODAY ()
                        VAR FMY = [Year Month]
                        VAR FilteredTable =
                                FILTER (FiscalCalendar , [Year Month] =  FMY )
                         //Fiscal Month Start Date
                        VAR FMSD =
                            MINX ( FilteredTable, [Date] )
                        // Fiscal Month End Date
                        VAR FMED =
                            MAXX ( FilteredTable, [Date])
                        RETURN 
                            SWITCH ( TRUE (), td >= FMSD && td <= FMED, TRUE (), FALSE () )
                    )
RETURN RESULT

 

I have modified your DAX expression becuause few of the variables were missing.

 

Anyways you can use ADDCOLUMNS function as shown above.

 

Thanks and Regards

 

View solution in original post

13 REPLIES 13

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.

Top Solution Authors