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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
awaldron
Regular Visitor

How to determine text value to display from prior month

I am trying to create a SKU status based on the SKU creation date and the number of units sold in the last 12 months. If the SKU status is inactive, it needs to stay inactive, otherwise continue using the logic.

 

Below if my current DAX calculated column, but I need to figure out a way to make the SKU status remain Inactive once it becomes Inactive:

SKU Status = IF(
    [Date_time_year]=2019,
    "",
    IF([Month_Diff]<12,
    "Active",
    IF(CALCULATE(MAX([Month_Diff]))<37,
    "Active",
    IF(Summary Facts'[Sales_Qty_L12M]<51,
    "Inactive",
    "Active"))))

Below is an example output:

awaldron_0-1701376213799.png

 

1 ACCEPTED SOLUTION
123abc
Resident Rockstar
Resident Rockstar

Your current DAX formula looks close, but it needs a modification to ensure that once the SKU status becomes "Inactive," it remains "Inactive" in the future months. You can achieve this by introducing an additional condition to check if the current SKU status is "Inactive" and if the current month difference is greater than or equal to 12.

Here's a modified version of your DAX formula:

 

SKU Status =
IF(
[Date_time_year] = 2019,
"", -- Assuming you want a blank value for the year 2019
IF(
[Month_Diff] < 12,
"Active",
IF(
CALCULATE(MAX([Month_Diff])) < 37,
"Active",
IF(
SummaryFacts'[Sales_Qty_L12M] < 51,
"Inactive",
IF(
[Previous_SKU_Status] = "Inactive" && [Month_Diff] >= 12,
"Inactive",
"Active"
)
)
)
)
)

 

In this modification, I introduced a hypothetical [Previous_SKU_Status] column, which represents the SKU status in the previous month. You should replace [Previous_SKU_Status] with the actual column or measure that represents the SKU status in the previous month.

This modification ensures that if the SKU status is "Inactive" and the current month difference is greater than or equal to 12, it remains "Inactive"; otherwise, it stays "Active." Adjust the column or measure names as needed based on your data model.

 
 
 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

View solution in original post

1 REPLY 1
123abc
Resident Rockstar
Resident Rockstar

Your current DAX formula looks close, but it needs a modification to ensure that once the SKU status becomes "Inactive," it remains "Inactive" in the future months. You can achieve this by introducing an additional condition to check if the current SKU status is "Inactive" and if the current month difference is greater than or equal to 12.

Here's a modified version of your DAX formula:

 

SKU Status =
IF(
[Date_time_year] = 2019,
"", -- Assuming you want a blank value for the year 2019
IF(
[Month_Diff] < 12,
"Active",
IF(
CALCULATE(MAX([Month_Diff])) < 37,
"Active",
IF(
SummaryFacts'[Sales_Qty_L12M] < 51,
"Inactive",
IF(
[Previous_SKU_Status] = "Inactive" && [Month_Diff] >= 12,
"Inactive",
"Active"
)
)
)
)
)

 

In this modification, I introduced a hypothetical [Previous_SKU_Status] column, which represents the SKU status in the previous month. You should replace [Previous_SKU_Status] with the actual column or measure that represents the SKU status in the previous month.

This modification ensures that if the SKU status is "Inactive" and the current month difference is greater than or equal to 12, it remains "Inactive"; otherwise, it stays "Active." Adjust the column or measure names as needed based on your data model.

 
 
 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors