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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
szhong6
New Member

How to get the slicer value

I created a slicer and a measure, and the measure works fine in the card object.

SelectedDate = SELECTEDVALUE('Calendar'[Date],"2022-8-5")

When I want to use the measure in a new table, it doesn't work and returns a value of "2022-8-5".

At this Link learned that ABC cannot be used in new tables.

SELECTEDVALUE doesn't work in a measure table - Microsoft Fabric Community

 

But I have to connect with the slicer in a new table, is there any other way?

 

 

Data = 

    Var SelectedDate = 'Calendar'[SelectedDate]  //this is a measure.
    var MaxYear = YEAR(SelectedDate)
    var MaxMonth = MONTH(SelectedDate)
    var MaxWeek = WEEKNUM(SelectedDate)
    
return

    UNION(
        //年 - 小于筛选年份的所有行. 
        //Year - All rows that are less than thse filtered year.
        ADDCOLUMNS(FILTER(Source,Source[Year] <= MaxYear),                                                          "Axis",Source[Year],            "Order",Source[Year] * 1),
        //月 - 筛选年份小于筛选月份的所有行.
        //year month - All rows with a filter year less than the filter month.
        ADDCOLUMNS(FILTER(Source,Source[Year] = MaxYear && Source[Month] <= MaxMonth),                              "Axis",Source[YearMonth],       "Order",Source[Month] * 10000),
        //周 - 筛选年份&筛选月份的所有行.
        //year week - 
        ADDCOLUMNS(FILTER(Source,Source[Year] = MaxYear && Source[Month] = MaxMonth),                               "Axis",Source[YearWeek],        "Order",Source[Week] * 1000000),
        //日 - 筛选年份&筛选月份&筛选周的所有行.
        //year week day
        ADDCOLUMNS(FILTER(Source,Source[Year] = MaxYear && Source[Month] = MaxMonth && Source[Week] = MaxWeek),     "Axis",Source[YearWeekDay],     "Order",Source[WeekDay] * 100000000)
    )
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @szhong6 ,

You mentioned that when you use the SELECTEDVALUE function in a normal data table, it works fine. However, when you apply it in a table created by a DAX formula, it doesn’t work as expected.
The reason for this behavior lies in how calculated tables are evaluated. Unlike columns in a normal data table, calculated tables are static and do not dynamically update based on slicer interactions.

powerbi - Using DAX with a SELECTEDVALUE From Slicer Not Working correctly - Stack Overflow

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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 @szhong6 ,

You mentioned that when you use the SELECTEDVALUE function in a normal data table, it works fine. However, when you apply it in a table created by a DAX formula, it doesn’t work as expected.
The reason for this behavior lies in how calculated tables are evaluated. Unlike columns in a normal data table, calculated tables are static and do not dynamically update based on slicer interactions.

powerbi - Using DAX with a SELECTEDVALUE From Slicer Not Working correctly - Stack Overflow

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

 

szhong6
New Member

Snipaste_2023-12-25_15-00-41.png

 

The chart I want to implement is something like this, showing different levels of content in the same column chart, and it's already done. 

But I also wanted it to be able to link with the slicer.

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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