DAX HANDBOOK
4.4 Table to Scalar Transformation

If you wish to follow along, you can find PBIX/Excel files at the bottom of the article. 

Authors

Krešimir Ledinski

Krešimir Ledinski

Microsoft certified expert in the field of Business Intelligence. His biggest passions are DAX, M, and data modeling.

Kristian Radoš

Kristian Radoš

Experienced data analyst. Advanced in SQL, PowerApps and M language.

Explanation

All table functions have one special feature. If the result of the table function returns exactly one row and a single column, its result is automatically transformed into a scalar which can be shown in a visual.

NumberOfCategories = COUNTROWS(VALUES(Sales[CategoryName]))
NameOfCategory = IF(COUNTROWS(VALUES(Sales[CategoryName]))=1,VALUES(Sales[CategoryName]),"Multi category")

The [NumberOfCategories] is a measure that counts the number of unique CategoryNames from the Sales table, taking into account the Color filter on the visual. We can see that Multi and White colors have only one type of CategoryName. VALUES function used a single column as an argument, and that column, when filtered by colors Multi and White, returns only a single row. When a table function returns only one row and one column, its result is automatically transformed into a scalar which can be represented in a visual. That’s why we receive “Clothing” text as a result of a measure for the mentioned colors.

Important

When using this technique, it’s extremely important to always secure the Measure to perform scalar transformation only in case the 1 row 1 column rule is secured. In our case, we implemented an IF condition, which counts the number of rows in a table that the VALUES function returns. If count does not equal to 1, then the text returned in a visual is “Multi category”. If the value equals 1, it means it’s safe to make table to scalar transformation and we simply return the result of the VALUES function.

Table to scalar transformation occurs for every table function which, after evaluation, returns a single row and a single column.

[NameOfCategory] measure can be also written with a sugar syntax function SELECTEDVALUE(ColumnName, “Alternate Result”).

Materials

We wish to create the best possible content!

If you are a novice looking for a better explanation of any element of the topic, feel free to comment on the part you didn't quite understand!

If you are an expert in DAX and believe certain topic lacks important internals, your comments are more than welcomed!

COMMENTS

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

OUR SERVICES

Prefer live training or consultations?

Table of Content

Table of Content

GET LATEST BI NEWS TO YOUR INBOX

Receive the latest updates on all business analyst news across all platforms.

By subscribing you are agreeing to our Privacy Policy.

Related blog posts

New Power BI training held for client Bugatti Rimac

In the past 2 weeks, we held a new Power BI training for the client Bugatti Rimac for a total duration of 24 hours. The training was held again at the client’s on Campus, but this time for another department, the Project Logistics team. The participants of the training with...

Read more

Nova održana Power BI edukacija za klijenta Bugatti Rimac

U protekla 2 tjedna održali smo novu Power BI edukaciju za klijenta Bugatti Rimac u sveukupom trajanju od 24 sata. Edukacija je ponovno održana kod klijenta na Kampusu, ali ovaj put za drugi odjel, tim Projektne Logistike. Polaznici edukacije uz pomoć Power BI sustava žele automatizirati svakodnevne zadatke i stvoriti...

Read more

Held PowerApps training for Žito d.d.

Last week we went to Osijek to hold a PowerApps training for Žito d.d. The training took place at the client’s office, lasting 2 days, with a total duration of 8 hours. The participants of the training have been using PowerApps in their business for some time, but they wanted...

Read more

Održana PowerApps edukacija za Žito d.d.

Prošli tjedan svratili smo do Osijeka kako bismo održali PowerApps edukaciju za Žito d.d. Edukacija se održala u 2 dana kod klijenta u uredu, u sveukupnom trajanju od 8 sati. Polaznici edukacije već neko vrijeme koriste PowerApps u svom poslovanju, no željeli su usavršiti svoje vještine u samostalnoj izradi aplikacija,...

Read more
0
Would love your thoughts, please comment.x
()
x
Scroll to Top