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
ogend
Helper I
Helper I

exclude record from analysis if prior year activity doesn't exist with time intelligence approach

hi BI Gurus, 

 

My Table looks like this:

PeriodScenarioDepartment Revenue
Dec-17Actualdepartment1500
Mar-18Forecastdepartment1550
Jun-18Forecastdepartment1600
Sep-18Forecastdepartment1500
Dec-18Forecastdepartment1530
Dec-18Actualdepartment1535
Mar-19Forecastdepartment1580
Jun-19Forecastdepartment1600
Sep-19Forecastdepartment1620
Dec-19Forecastdepartment1590
Dec-19Actualdepartment1600
Mar-20Forecastdepartment1620
Jun-20Forecastdepartment1630
Sep-20Forecastdepartment1620
Dec-20Forecastdepartment1610
Dec-20Actualdepartment1600
Dec-17Actualdepartment2575
Mar-18Forecastdepartment2633
Jun-18Forecastdepartment2690
Sep-18Forecastdepartment2575
Dec-18Forecastdepartment2610
Dec-18Actualdepartment2615
Mar-19Forecastdepartment2667
Jun-19Forecastdepartment2690
Sep-19Forecastdepartment2713
Dec-19Forecastdepartment2679
Dec-19Actualdepartment2690
Mar-20Forecastdepartment2713
Jun-20Forecastdepartment2725
Sep-20Forecastdepartment2713
Dec-20Forecastdepartment2702
Dec-20Actualdepartment2700
Dec-19Actualdepartment 3345
Mar-20Forecastdepartment 3357
Jun-20Forecastdepartment 3362
Sep-20Forecastdepartment 3357
Dec-20Forecastdepartment 3351
Dec-20Actualdepartment 3350

 

my goal is to get to this view  so that Current year is picked from a slicer and prior year is dinamically calculated  as curent year - 1

 PYForecast03Forecast06Forecast09Forecast12CY
department1600620630620610600
department2690713725713702700
department 3345356.5362.25356.5350.75350

 

I was able to get to this with setting up a date table and using the year from the date table in the slicer 

 

Here is what i don't know how to aproach:

 

per above data if current year is 2019- department 3 doesn't have any activity for prior year, the record for 2018 activity doesn't exist

2018    2019
 PYForecast03Forecast06Forecast09Forecast12CY
department1535580600620590600
department2615667690713679690
department 3     345

 

 

i want to exclude department 3 scenario from analyis . would you please advise? If prior year record for scenario= "Actual"  doesn't exist or is 0 or is null - do not include department in the calc, however if i selected 2020 as my current year- i would need department 3 to show since it does have activity for 2019.

 

Thank you!

 

Olga

2 ACCEPTED SOLUTIONS

Hi @lbendlin , 

 

my CY Measure is 

 CY=CALCULATE(SUM('Table'[Revenue]),FILTER('Table','Table'[Scenario]="Actual"),FILTER('Date','Date'[CurrentYear]='Date'[CurrentYear])
can you please explain what you  mean ? Sorry, i am super new to Power BI. 
 
Olga

View solution in original post

lbendlin
Super User
Super User

your last filter is meaningless

FILTER('Date','Date'[CurrentYear]='Date'[CurrentYear])

 

your measure seems to be missing a closing bracket.

 

Your measure should look similar to this:

 

 CY=

var m = max('Date'[CurrentYear])

var p = CALCULATE(SUM('Table'[Revenue]), 'Table'[Scenario]="Actual", FILTER('Date','Date'[CurrentYear]=m-1) )

return if (ISBLANK(p),BLANK(),CALCULATE(SUM('Table'[Revenue]),'Table'[Scenario]="Actual"))

 

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

Remember that measures are computed for all elements of a visual - table cells, row and column subtotals, and the grand total. That means you have to consider up to four different computations depending on what you want to achieve.

I found that starting from the perspective of the grand total is the most effective way.

lbendlin
Super User
Super User

your last filter is meaningless

FILTER('Date','Date'[CurrentYear]='Date'[CurrentYear])

 

your measure seems to be missing a closing bracket.

 

Your measure should look similar to this:

 

 CY=

var m = max('Date'[CurrentYear])

var p = CALCULATE(SUM('Table'[Revenue]), 'Table'[Scenario]="Actual", FILTER('Date','Date'[CurrentYear]=m-1) )

return if (ISBLANK(p),BLANK(),CALCULATE(SUM('Table'[Revenue]),'Table'[Scenario]="Actual"))

 

 

Thanks for the explanation, @lbendlin , this approach does work for dropping department 3 from the visual, but subtotal in the visual is still picking up department 3. is there any way to modify the formula so it subtotals only visible rows or creating separate mesuares and using Union to bring them in place of subtotals is my only choice? 

lbendlin
Super User
Super User

All you need to do is BLANK() out measure CY for that scenario - then department 3 will disappear from the visual

Hi @lbendlin , 

 

my CY Measure is 

 CY=CALCULATE(SUM('Table'[Revenue]),FILTER('Table','Table'[Scenario]="Actual"),FILTER('Date','Date'[CurrentYear]='Date'[CurrentYear])
can you please explain what you  mean ? Sorry, i am super new to Power BI. 
 
Olga

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.