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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
joelmsherman
Frequent Visitor

Simple Calculated Column?

Hi folks,

 

I've got a basic Date table with a DIMDate[Date] primary key.  

 

I'm trying to create a boolean calculated column that determines if the [Date] is part of a completed school year.  New school years start at the Month of September.  Here's what I've tried with no luck:

 

School Year Completed = 
VAR YearCheck = YEAR(DIMDate[Date]) <= YEAR(Today())
VAR MonthCheck = MONTH(DIMDate[Date]) < 9

VAR Result = YearCheck && MonthCheck

RETURN Result

 

My table has data from January 1, 2015 through December 31, 2022.  I expect the DAX to return TRUE for all dates up to August 31, 2022, and FALSE thereafter.  But not working.  It is ignoring my YearCheck condition, and returning FALSE in any year so long as month greater than or equal to 9

1 ACCEPTED SOLUTION

aha, try this

 

School Year Completed =
VAR YearCheck = YEAR(DIMDate[Date]) 
VAR MonthCheck = MONTH(DIMDate[Date]) 
VAR Result = 
IF (
    YEAR(DIMDate[Date]) >= YEAR(Today())
        &&MONTH(DIMDate[Date]) >= 9,
    FALSE,
    TRUE
)
RETURN Result

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

try this,

 

School Year Completed =
VAR YearCheck = YEAR(DIMDate[Date]) 
VAR MonthCheck = MONTH(DIMDate[Date]) 
VAR Result = 
IF (
    YEAR(DIMDate[Date]) <= YEAR(Today())
        &&MONTH(DIMDate[Date]) < 9,
    TRUE,
    FALSE
)
RETURN Result

 

Still no luck:

 

DAXIssue.png

aha, try this

 

School Year Completed =
VAR YearCheck = YEAR(DIMDate[Date]) 
VAR MonthCheck = MONTH(DIMDate[Date]) 
VAR Result = 
IF (
    YEAR(DIMDate[Date]) >= YEAR(Today())
        &&MONTH(DIMDate[Date]) >= 9,
    FALSE,
    TRUE
)
RETURN Result

Boom!  The converse logic works!  Thanks much.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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