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
Hayleysea
Resolver II
Resolver II

Previous month not equal to 0, current month equal to 0 column or measure to use as filter

Hi there,

 

I have a table which has a date column with data over several years. I need a measure or column to indicate the following:

 

- The previous month to today entered value <> 0 (column called actuals) - so they entered a value

- The current month has entered value = 0 or Blank (same column called actuals) - so no value has been entered

 

There are several lines for one project so it needs to check that the sum of all project ID's for the month is or is not = 0 for the current and previous months.

 

Ultimately this will be used as a filter in a table to call out the ones that entered values last month but haven't yet this month.

 

Thankyou!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Hayleysea -

In cases like this I prefer to use a Date table with Relative Months. There are many ways to create a date dimension, one describing relative dates is here. I've also attached an alternative.

 

Once you have your date dimension with relative dates, you can create a measure like the following.

Notes:

  1. This can be extended to apply to any month by using "MAX('Date'[Relative Month])" instead of 0.
  2. This could also be extended to classify Churn, New, Returning, Existing.

 

Actual Churn This Month = 
var _MonthToAnalyze = 0 --MAX('Date'[Relative Month])
var _CurrentMonthActuals =
    CALCULATE(
        [Sales],
        'Date'[Relative Month] = _MonthToAnalyze
    ) + 0
var _PreviousMonthActuals =
    CALCULATE(
        [Sales],
        'Date'[Relative Month] = _MonthToAnalyze - 1
    ) + 0
return 
    AND(
        _PreviousMonthActuals <> 0,
        _CurrentMonthActuals = 0
    )

 

You can use this measure as a filter to only keep True values.

 

I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.
Nathan Peterson

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Hayleysea -

In cases like this I prefer to use a Date table with Relative Months. There are many ways to create a date dimension, one describing relative dates is here. I've also attached an alternative.

 

Once you have your date dimension with relative dates, you can create a measure like the following.

Notes:

  1. This can be extended to apply to any month by using "MAX('Date'[Relative Month])" instead of 0.
  2. This could also be extended to classify Churn, New, Returning, Existing.

 

Actual Churn This Month = 
var _MonthToAnalyze = 0 --MAX('Date'[Relative Month])
var _CurrentMonthActuals =
    CALCULATE(
        [Sales],
        'Date'[Relative Month] = _MonthToAnalyze
    ) + 0
var _PreviousMonthActuals =
    CALCULATE(
        [Sales],
        'Date'[Relative Month] = _MonthToAnalyze - 1
    ) + 0
return 
    AND(
        _PreviousMonthActuals <> 0,
        _CurrentMonthActuals = 0
    )

 

You can use this measure as a filter to only keep True values.

 

I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.
Nathan Peterson

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.