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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.