This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreGet Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.
I have a column chart with a measure that calculates the budget. I also have a slicer with a date range from my calendar date table (Dim_Date). I want to set the date range slicer to span 2 different years (i.e. 6/1/21 - 3/31/22) and have the budget apply one measure for 2021 and a different measure for 2022. Below is the DAX for my measure. This works as long as the date range is either 2021 or 2022 but not when it spans both years. Thanks for any help that can be provided.
Budget =
if(SELECTEDVALUE(VW_DIM_DATE[YEAR]) >= 2022,
[Budget 2022],
[Budget Pre:2022])
Solved! Go to Solution.
Thank you for the quick attention Vahid. I only want to add one measure to the visual where the measure applies a [Budget 2022] sub measure to all months from the slicer in 2022 and applies the [Budget Pre:2022] sub measure for all months from the slicer before 2022. Below is the DAX for each of these two sub measures:
Budget 2022 =
if(
SELECTEDVALUE('Product Bridge'[Product]) = "RBC",
SUM(VW_VTL_DAILY_BUDGET[ADJ_RBC_PRODUCT]),
sum(VW_VTL_DAILY_BUDGET[ADJ_PLT_PRODUCT]))
Budget Pre:2022 = CALCULATE(sum('Daily Goals'[RBC Daily Budget]))
The reason I am doing this is because the goals prior to 2022 come from the 'Daily Goals' table and the goals for 2022 come from the 'VTL Daily Budget' table (different layouts for each table). Each of the individual measures works fine I just can't get the parent measure to apply the sub measures appropriately for months that span both years.
Thanks, Steve
Hi @Sony
Try these measures:
understand you want two measures to calculate the BUDGET for years 2021 and 2021, and I considered there is a relationship between your calendar table and fact table:
Budget (2021) =
VAR _MinDate =
MIN( VW_DIM_DATE[DATE] )
VAR _MinY =
MIN( VW_DIM_DATE[YEAR] )
VAR _MaxY =
MAX( VW_DIM_DATE[YEAR] )
RETURN
IF(
_MinY <> 2021,
0,
IF(
_MaxY = 2021,
SUM( table[Budget] ),
CALCULATE(
SUM( table[Budget] ),
FILTER(
ALL( table ),
Table[Date] >= _MinDate
&& Table[Date] <= DATE( 2021, 12, 31 )
)
)
)
)
Budget (2022) =
VAR _MaxDate =
MAX( VW_DIM_DATE[DATE] )
VAR _MinY =
MIN( VW_DIM_DATE[YEAR] )
VAR _MaxY =
MAX( VW_DIM_DATE[YEAR] )
RETURN
IF(
_MaxY <> 2022,
0,
IF(
_MinY = 2022,
SUM( table[Budget] ),
CALCULATE(
SUM( table[Budget] ),
FILTER(
ALL( table ),
Table[Date] >= DATE( 2022, 01, 01 )
&& Table[Date] <= _MaxDate
)
)
)
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Thank you for the quick attention Vahid. I only want to add one measure to the visual where the measure applies a [Budget 2022] sub measure to all months from the slicer in 2022 and applies the [Budget Pre:2022] sub measure for all months from the slicer before 2022. Below is the DAX for each of these two sub measures:
Budget 2022 =
if(
SELECTEDVALUE('Product Bridge'[Product]) = "RBC",
SUM(VW_VTL_DAILY_BUDGET[ADJ_RBC_PRODUCT]),
sum(VW_VTL_DAILY_BUDGET[ADJ_PLT_PRODUCT]))
Budget Pre:2022 = CALCULATE(sum('Daily Goals'[RBC Daily Budget]))
The reason I am doing this is because the goals prior to 2022 come from the 'Daily Goals' table and the goals for 2022 come from the 'VTL Daily Budget' table (different layouts for each table). Each of the individual measures works fine I just can't get the parent measure to apply the sub measures appropriately for months that span both years.
Thanks, Steve
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |