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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
erhan_79
Post Prodigy
Post Prodigy

Status Formula

Hi there ;

 

i need DAx formula for below issue thanks for your kind supports 

 

i have a table as below Delivery date and Quantity , i need to create a new column which show the status as i wanted.

 

so the rule will be like that :  

 

Our current  month is  : July 2020 

 

İf delivery date is in the current month  status will be "actual month"

 

if delivery dates will be before current month status  will be  "Previous Month " 

 

İf delivery date will be after current month Status will be " Next Month" 

 

Capture1.JPG

 

 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to do it with a DAX calculated column.  Replace with your actual Table[Column] name that has your dates.

 

Status of Month =
VAR todaysdate =
    TODAY ()
VAR mindate =
    DATE ( YEAR ( todaysdate ), MONTH ( todaysdate ), 1 )
VAR maxdate =
    EOMONTH ( TODAY (), 0 )
RETURN
    SWITCH (
        TRUE (),
        Sales[SaleDate] < mindate, "Previous Month",
        Sales[SaleDate] > maxdate, "Next Month",
        "Actual Month"
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
harshnathani
Community Champion
Community Champion

Hi @erhan_79 ,

 

 

Create a Calculated Column

 

 

Column =
VAR _month =
    MONTH ( Table[DeliveryDate] )
VAR _year =
    YEAR ( Table[DeliveryDate] )
VAR _monthcurrent =
    MONTH (
        TODAY ()
    )
VAR _yearcurrent =
    YEAR (
        TODAY ()
    )
RETURN
    SWITCH (
        TRUE (),
        _year < _currentyear, "Previous Month",
        _year = _yearcurrent
            && _month < _monthcurrent, "Previous Month",
        _year = _yearcurrent
            && _month = _monthcurrent, " Actual Month",
        "Next Month"
    )

 

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to do it with a DAX calculated column.  Replace with your actual Table[Column] name that has your dates.

 

Status of Month =
VAR todaysdate =
    TODAY ()
VAR mindate =
    DATE ( YEAR ( todaysdate ), MONTH ( todaysdate ), 1 )
VAR maxdate =
    EOMONTH ( TODAY (), 0 )
RETURN
    SWITCH (
        TRUE (),
        Sales[SaleDate] < mindate, "Previous Month",
        Sales[SaleDate] > maxdate, "Next Month",
        "Actual Month"
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.