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
OmarSek
Regular Visitor

Get a field data based on a slicer using dax measure

I create a table called KPI BY YEAR , with two columns YEAR and Num KPI , this table has a relationship with just Date table . 

Year           Num KPI

2020         10

2021          12

I have also a slicer on a month using a date column of table Date, i am trying just to find the NUM KPI using dax formula but it doesn't function. 

 

This is my dax forumula : 

 

NumPKIYEAR = VALUES ('KPI BY YEAR'[Num KPI]) 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @OmarSek 

The ‘VALUES ’ function is not normally used to return a single value. It returns a one-column table that contains the distinct values from the specified column. So it should be applied to the creation of table(such as calculated tables or  temporary tables in measure)

Please try code like below to find the NUM KPI :

NumPKIYEAR =
CALCULATE (
    MAX ( 'KPI BY YEAR'[Num KPI] ),
    FILTER (
        ALL ( 'KPI BY YEAR' ),
        'KPI BY YEAR'[Year] = SELECTEDVALUE ( 'Date'[Year] )
            && 'KPI BY YEAR'[Month] = SELECTEDVALUE ( 'Date'[Month] )
    )
)

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi, @OmarSek 

The ‘VALUES ’ function is not normally used to return a single value. It returns a one-column table that contains the distinct values from the specified column. So it should be applied to the creation of table(such as calculated tables or  temporary tables in measure)

Please try code like below to find the NUM KPI :

NumPKIYEAR =
CALCULATE (
    MAX ( 'KPI BY YEAR'[Num KPI] ),
    FILTER (
        ALL ( 'KPI BY YEAR' ),
        'KPI BY YEAR'[Year] = SELECTEDVALUE ( 'Date'[Year] )
            && 'KPI BY YEAR'[Month] = SELECTEDVALUE ( 'Date'[Month] )
    )
)

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@OmarSek , a calculated table will not take slicer value.

 

Join with a join table, have year, month, Qtr column in the table and use that to plot year wise data in visual

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  i understand the reason , but the can you explain more the solution. Thanks

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.