{"id":1840,"date":"2020-11-20T09:47:45","date_gmt":"2020-11-20T09:47:45","guid":{"rendered":"https:\/\/bi.unija.com\/en\/?p=1840"},"modified":"2020-11-27T12:57:33","modified_gmt":"2020-11-27T12:57:33","slug":"functions-values-hasonevalue","status":"publish","type":"post","link":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/","title":{"rendered":"DAX function VALUES, HASONEVALUE"},"content":{"rendered":"<p><em>For Power BI version 2.76.5678.782 (December 2019).<\/em><\/p>\n<h1>Function VALUES()<\/h1>\n<p>Function <strong>VALUES()<\/strong> returns a column of unique values. Function takes in initial filter context that comes from visualizations and slicers. You can find more on filter context in <a href=\"https:\/\/bi.unija.com\/en\/filter-context-in-power-bi\/\">Filter context in Power BI<\/a>.<\/p>\n<h2>Syntax<\/h2>\n<p>VALUES(TableOrColumnName)<\/p>\n<table>\n<tbody>\n<tr>\n<td>Parameter<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>TableOrColumnName<\/td>\n<td>Column where we want to keep only unique values or table where we want to keep only unique rows<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Example: unique values from a column<\/h2>\n<p>We want unique values from <strong>Location Name<\/strong> column in the <strong>Sales<\/strong> table.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"140\" height=\"525\" class=\"wp-image-1841\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-12.png\" srcset=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-12.png 140w, https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-12-80x300.png 80w\" sizes=\"(max-width: 140px) 100vw, 140px\" \/><\/p>\n<p>We create new table with <strong>Modelling &gt;<\/strong> <strong>New Table<\/strong> and enter the following formula.<\/p>\n<p>VALUES_Example = VALUES(Sales[Location Name])<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"146\" height=\"246\" class=\"wp-image-1842\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-13.png\" \/><\/p>\n<h2>Example: filter context and VALUES()<\/h2>\n<p>Function <strong>VALUES()<\/strong> takes in the initial filter context coming from visualizations and slicers. Let&#8217;s look at the last example. We have sales table <strong>Sales<\/strong> with columns <strong>Platform<\/strong> and <strong>Publisher<\/strong>. We create Matrix visualization and insert field Platform to rows. We then create the following measure.<\/p>\n<p>VALUES_Example = COUNTROWS(VALUES(Sales[Publisher]))<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"187\" height=\"223\" class=\"wp-image-1843\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-14.png\" \/><\/p>\n<p>Function takes in the initial filter context, coming from Matrix visualization. Table <strong>Sales<\/strong> is filtered for each row to the appropriate <strong>Platform<\/strong>. Unique values in column <strong>Publisher<\/strong> is then counted.<\/p>\n<h1>Function HASONEVALUE()<\/h1>\n<p>Returns TRUE if only one value remains after filter context. Otherwise returns FALSE:<\/p>\n<h2>Syntax<\/h2>\n<p>HASONEVALUE(ColumnName)<\/p>\n<table>\n<tbody>\n<tr>\n<td>Parameter<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>ColumnName<\/td>\n<td>Column, that has one or more unique values<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Example<\/h2>\n<p>We have a table <strong>Platform_measures<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"182\" height=\"244\" class=\"wp-image-1844\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-15.png\" \/><\/p>\n<p>We wish to check if each Platform is repeated only once. We create a measure.<\/p>\n<p>HASONEVALUE_Example = HASONEVALUE(Locations_measures[Platform])<\/p>\n<p>We have to create a new Matrix visualization and insert <strong>Platform<\/strong> to rows. Visualization filters the table <strong>Platform_measures<\/strong> inside every row and returns TRUE for all rows, meaning each <strong>Platform<\/strong> indeed only occur once.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"225\" height=\"217\" class=\"wp-image-1845\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-16.png\" \/><\/p>\n<h1>Function SELECTEDVALUE()<\/h1>\n<p>Returns value, if only one value is left after filter context. Otherwise returns BLANK().<\/p>\n<h2>Syntax<\/h2>\n<p>SELECTEDVALUE(ColumnName, [AlternativeResult])<\/p>\n<table>\n<tbody>\n<tr>\n<td>Parameter<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>ColumnName<\/td>\n<td>Column that has one or more unique values<\/td>\n<\/tr>\n<tr>\n<td>AlternativeResult<\/td>\n<td>Value returned in case more than one value is left after filter context. Default value for this parameter is BLANK(). (optional)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Example<\/h2>\n<p>We have <strong>Platform_measures <\/strong>table.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"182\" height=\"244\" class=\"wp-image-1846\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-17.png\" \/><\/p>\n<p>We want to check if each value only shows up once and return it&#8217;s values it that&#8217;s true. We create new measure.<\/p>\n<p>SELECTEDVALUE_Example = SELECTEDVALUE(Platform_measures[Platform])<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"390\" height=\"212\" class=\"wp-image-1847\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-18.png\" srcset=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-18.png 390w, https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/word-image-18-300x163.png 300w\" sizes=\"(max-width: 390px) 100vw, 390px\" \/><\/p>\n<p>Table <strong>Platform_measures <\/strong>is filtered by initial filter context and then filtered by each row. One row is left for each platform. Value of platform is returned.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For Power BI version 2.76.5678.782 (December 2019). Function VALUES() Function VALUES() returns a column of unique values. Function takes in initial filter context that comes from visualizations and slicers. You can find more on filter context in Filter context in<\/p>\n","protected":false},"author":5,"featured_media":1849,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[5,8],"class_list":["post-1840","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-intermediate","tag-dax","tag-power-bi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>DAX function VALUES, HASONEVALUE - Bi Unija<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DAX function VALUES, HASONEVALUE - Bi Unija\" \/>\n<meta property=\"og:description\" content=\"For Power BI version 2.76.5678.782 (December 2019). Function VALUES() Function VALUES() returns a column of unique values. Function takes in initial filter context that comes from visualizations and slicers. You can find more on filter context in Filter context in\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/\" \/>\n<meta property=\"og:site_name\" content=\"Bi Unija\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-20T09:47:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-27T12:57:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"480\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Branka Trifunovi\u0107\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Branka Trifunovi\u0107\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/\",\"url\":\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/\",\"name\":\"DAX function VALUES, HASONEVALUE - Bi Unija\",\"isPartOf\":{\"@id\":\"https:\/\/bi.unija.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png\",\"datePublished\":\"2020-11-20T09:47:45+00:00\",\"dateModified\":\"2020-11-27T12:57:33+00:00\",\"author\":{\"@id\":\"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10\"},\"breadcrumb\":{\"@id\":\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#primaryimage\",\"url\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png\",\"contentUrl\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png\",\"width\":720,\"height\":480},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/bi.unija.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DAX function VALUES, HASONEVALUE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bi.unija.com\/en\/#website\",\"url\":\"https:\/\/bi.unija.com\/en\/\",\"name\":\"Bi Unija\",\"description\":\"Just another Bi site\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bi.unija.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10\",\"name\":\"Branka Trifunovi\u0107\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bi.unija.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g\",\"caption\":\"Branka Trifunovi\u0107\"},\"url\":\"https:\/\/bi.unija.com\/en\/author\/branka\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"DAX function VALUES, HASONEVALUE - Bi Unija","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/","og_locale":"en_US","og_type":"article","og_title":"DAX function VALUES, HASONEVALUE - Bi Unija","og_description":"For Power BI version 2.76.5678.782 (December 2019). Function VALUES() Function VALUES() returns a column of unique values. Function takes in initial filter context that comes from visualizations and slicers. You can find more on filter context in Filter context in","og_url":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/","og_site_name":"Bi Unija","article_published_time":"2020-11-20T09:47:45+00:00","article_modified_time":"2020-11-27T12:57:33+00:00","og_image":[{"width":720,"height":480,"url":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png","type":"image\/png"}],"author":"Branka Trifunovi\u0107","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Branka Trifunovi\u0107","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/","url":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/","name":"DAX function VALUES, HASONEVALUE - Bi Unija","isPartOf":{"@id":"https:\/\/bi.unija.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#primaryimage"},"image":{"@id":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#primaryimage"},"thumbnailUrl":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png","datePublished":"2020-11-20T09:47:45+00:00","dateModified":"2020-11-27T12:57:33+00:00","author":{"@id":"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10"},"breadcrumb":{"@id":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#primaryimage","url":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png","contentUrl":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/11\/33-EN.png","width":720,"height":480},{"@type":"BreadcrumbList","@id":"https:\/\/bi.unija.com\/en\/functions-values-hasonevalue\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bi.unija.com\/en\/"},{"@type":"ListItem","position":2,"name":"DAX function VALUES, HASONEVALUE"}]},{"@type":"WebSite","@id":"https:\/\/bi.unija.com\/en\/#website","url":"https:\/\/bi.unija.com\/en\/","name":"Bi Unija","description":"Just another Bi site","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bi.unija.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10","name":"Branka Trifunovi\u0107","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bi.unija.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g","caption":"Branka Trifunovi\u0107"},"url":"https:\/\/bi.unija.com\/en\/author\/branka\/"}]}},"_links":{"self":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1840"}],"collection":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/comments?post=1840"}],"version-history":[{"count":5,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1840\/revisions"}],"predecessor-version":[{"id":1853,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1840\/revisions\/1853"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/media\/1849"}],"wp:attachment":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/media?parent=1840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/categories?post=1840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/tags?post=1840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}