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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cinni_mini
Regular Visitor

Dynamic measure using SELECTEDVALUE to set base date

Hi community,

 

I have the following DAX to calculated indices based on the set base date. In my DAX right now the base date is static and set at 01.31.2022, which works fine and also gives the right outputs over time. But if I would subsitute the static base date with VAR SelectedBaseDate = SELECTEDVALUE(CalendarTable[Date]) (slicer selection) it doesn't work anymore. Can someone help me?

 

First DAX:

Base Date Index Value =
VAR SelectedBaseDate = DATE(2022, 1, 31) -- Fallback to a default date if none is selected
RETURN
CALCULATE(
MAX(Component_Index_Values[Component Index Value]),
ALL(CalendarTable), -- Ignoring slicer selections on CalendarTable
Component_Index_Values[Component Index Date] = SelectedBaseDate
)
 
2nd DAX based on results of 1st DAX:
 Component Index Value (from Base Date) =
VAR CurrentIndexValue = MAX('Component_Index_Values'[Component Index Value])
VAR BaseIndexValue = [Component Base Index Value] -- This should fetch the base index value correctly now
RETURN
IF(
NOT ISBLANK(BaseIndexValue) && BaseIndexValue <> 0,
(CurrentIndexValue / BaseIndexValue) * 100,
BLANK()
)
 
The date selection is controlled by a single choice slicer. Thanks! Looking forward to your advices.
2 REPLIES 2
cinni_mini
Regular Visitor

Hi Yang,

 

thanks for reaching out. It still doesn't work, the measure work with a static date, but doesn't take the value from the slicer. Do you have any recommendations why the slicer value is not taken by the measure DAX? Thanks!

 

Best

Anonymous
Not applicable

Hi, @cinni_mini 

Based on your description, I have created some measures to achieve the effect you are looking for. Following picture shows the effect of the display.

vyaningymsft_0-1709693110487.png

 

Measure:

Base Date Index Value =

VAR _selectedBaseDate =

    SELECTEDVALUE ( CalendarTable[Component Index Date] )

VAR _baseDateIndexValue =

    CALCULATE (

        MAX ( Component_Index_Values[Component Index Value] ),

        FILTER (

            Component_Index_Values,

            Component_Index_Values[Component Index Date] = _selectedBaseDate

        ),

        ALL ( Component_Index_Values )

    )

RETURN

    _baseDateIndexValue

 

If this does not work, could you please share some sample data without sensitive information and expected output.


Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.