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

Return a result in another column based off a selected value

Hi all, 

 

I am hoping there is a guru on here who will enlighten me as I am hitting a wall on what I thought would be straight forward. 

 

I am creating a sales dashboard and want the main page to be dynamic base don the date selected in a slicer e.g:

 

YTD: Results for the year up to the date selected

MTD: Results for the month of the data selected i.e. if a user selected  1/10/20 June 2024, the month is June 2024

DAY: Results for the day selected

 

YTD and MTD are proving tricky. I can calcuate them individually no problem but it is the "making them dynamic part" that is confusing me.

 

I was hoping to achieve this with the "SELECTEDVALUE" function to return a specific column from my calendar table which I would then use in my measure, but it is the bold and underlined part that is completely stumping me. 

 

In my calendar table, I have a column called "MonthYearNum" which is simply the year and the month number so June 2023 is 202306. This is the column I want returned based on the user selection in the date slicer. 

 

 

JS_UNI4C_0-1717676794913.png

 

I was then hoping to use that value in a revenue measure along the lines of:

Revenue MTD = CALCULATE([SalesSum],FILTER('Calendar',
'Calendar'[Date] = [Selected month]))
 
[SalesSum] being my measure used which is calculating the sum of all sales but will be filtered down based on user selection.
[Selected month] being the MonthYearNum based off the date selection by the user.
 
My calendar is connected to my source data via the date in both tables. 
 
For the YTD value, I was simply going to filter it by
Revenue YTD = CALCULATE([SalesSum],FILTER('Calendar',
'Calendar'[Date] <= MAX([Selected month])
&&
'Calendar'[Date] = MAX([Selected year])))
 
If this won't work, any help would be appreciated to get a solution.
 
Can anyone help me with this???

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JS_UNI4C ,

 

For combining dynamic metrics with slicers, try the following formula:

SelectedMeasureType = SELECTEDVALUE('MeasureType'[Measure], "YTD")
Dynamic Revenue = 
SWITCH(
    [SelectedMeasureType],
    "YTD", [Revenue YTD],
    "MTD", [Revenue MTD],
    "DAY", [Revenue DAY]
)
Revenue DAY = 
CALCULATE(
    [SalesSum],
    FILTER(
        'Calendar',
        'Calendar'[Date] = SELECTEDVALUE('Calendar'[Date])
    )
)

vkongfanfmsft_0-1717743194244.png

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @JS_UNI4C ,

 

For combining dynamic metrics with slicers, try the following formula:

SelectedMeasureType = SELECTEDVALUE('MeasureType'[Measure], "YTD")
Dynamic Revenue = 
SWITCH(
    [SelectedMeasureType],
    "YTD", [Revenue YTD],
    "MTD", [Revenue MTD],
    "DAY", [Revenue DAY]
)
Revenue DAY = 
CALCULATE(
    [SalesSum],
    FILTER(
        'Calendar',
        'Calendar'[Date] = SELECTEDVALUE('Calendar'[Date])
    )
)

vkongfanfmsft_0-1717743194244.png

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi, 

 

Many thanks for the response and sorry for the lack of response on my part. Been a crazy few days but it is back to Power BI now so I will be giving this a go today! Hoping it works...!

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.