cancel
Showing results for
Did you mean:
Frequent Visitor

## Help with a formula for waterfall comparisons

Hi everyone.

Below is the formula I am currently using that is not working as I need it for my waterfall visual. I am trying to compare MTD and YTD values but I now know through validation it is using the wrong periods of time. I have a static date table with all dates that are relevant to my data and then a dynamic date table that outlines MTD, YTD and R12 (as you'll see in my RETURN function) that dictate the time period but I'm not sure if I can somehow use this in my actual CALCULATE functions above.

When using 2022 the values come out that the MTD this year is for September and the YTD is January to September, but when using 2021 MTD is December and YTD is January - December. How am I able to limit the date to only go to the maximum month of the most current year?

I'm only a few months into learning PBI so I've been picking things up online as I go but this one is stumping me. Thanks for the help!

Total Value Selector Actual =
VAR TVMTD =
-CALCULATE(
[Total Value],
FinancialsData[Actual/Budget/Forecast] = "Financial Actual",
DATESMTD(
CalendarLookup[Date]
)
)
VAR TVYTD =
-CALCULATE(
[Total Value],
FinancialsData[Actual/Budget/Forecast] = "Financial Actual",
DATESYTD(
CalendarLookup[Date]
)
)
RETURN
SWITCH(
TRUE(),
SELECTEDVALUE('DatePeriodsWaterfalls'[Type]) = "MTD",TVWMTD,
SELECTEDVALUE('DatePeriodsWaterfalls'[Type]) = "YTD",TVWYTD
)
4 REPLIES 4
Frequent Visitor

dforward3,

I have a couple of quick question to make sure I understand the situation.  It seems that you have a slicer/filter on the page so that you can select the year.  If so, when you select 2021, what data you are wanting to return?  I'm a bit confused because you say 2021, but then say the most current year, which I interpret as 2022.  Do you mean the max year selected in the slicer/filter?

Frequent Visitor

The slicer that I'm using on the page is actually a dynamic MTD/YTD slicer, not a manual time selection. I will post below the DAX I'm using for that table. This way, whenever I choose MTD it is giving me all dates in September of 2021 and 2022 respectively, which I'm only using for this Waterfall. My firm isn't concerned with particular dates, just the big time slices of MTD, YTD and R12.

With this, I'm just not sure if I can somehow use the dates from this table in my calculation. My logic in my head would read "if "Type" value is equal to MTD, use those dates to calculate the Total Value". I'm just unsure if I can use that here.

Sorry if I'm making this more confusing, it's definitely tough explaining structure without being able to show value. If there is also a potentially easier way to show a Waterfall with comparable MTD and YTD values, I'm all ears!

DatePeriodsWaterfalls =
UNION(
DATESMTD(CalendarLookup[Date]),
"Type","MTD",
"Order",1
),
DATESYTD(CalendarLookup[Date]),
"Type","YTD",
"Order",2
),
DATESINPERIOD(CalendarLookup[Date],MAX(CalendarLookup[Date]),-12,MONTH),
"Type","R12",
"Order",3
),
SAMEPERIODLASTYEAR(
DATESMTD(CalendarLookup[Date])),
"Type","MTD",
"Order",1
),
SAMEPERIODLASTYEAR(
DATESYTD(CalendarLookup[Date])),
"Type","YTD",
"Order",2
),
SAMEPERIODLASTYEAR(
DATESINPERIOD(CalendarLookup[Date],MAX(CalendarLookup[Date]),-12,MONTH)),
"Type","R12",
"Order",3
)
)
Frequent Visitor

Ah.  So you are trying to compare MTD for 2022 against the same period for 2021 (or YTD for 2022 against the same period for 2021)?

Frequent Visitor

Yep exactly! It's just pushing the months ahead to the latest dates in the previous years since we have full data for that year and incomplete (so far) for this year. I just need some sort of qualifier in the formula to not go past the current last month of the current year for the previous year.

Announcements

#### Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

#### Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

#### Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

#### Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors