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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rob_vander2
Frequent Visitor

Combination of two column values in DAX measure

Hi All, 

 

I have below dataset 

 

CatNameValue
aaa100
abb50
acc30
baa25
bcc65
caa70
cbb54
cdd34

 

I want to create visual report, with all combination values of Cat,Name like below. Wherever combination is not available in data, value should be blank in visual report

 

CatNameValue
aaa100
abb50
acc30
add 
baa25
bbb 
bcc65
bdd 
caa70
cbb54
ccc 
cdd34

 

I am struggling to create DAX measure for it. What is the best way to achive this?

 

 

2 ACCEPTED SOLUTIONS
sjoerdvn
Super User
Super User

I used the html to get the table data, and added dimensions in power query (there are many different ways of doing this, depending on data source and personal preferences)
I have added the relationships and created measures for examples with either a "0" or a blank with an extra column.

View solution in original post

v-yohua-msft
Community Support
Community Support

Hi, @rob_vander2 

Thanks for the reply from @SuperUser/@NormalUser, please allow me to provide another insight:

You can create a new table, use the crossjoin function 

 

Table 2 = CROSSJOIN(VALUES('Table'[Cat]),VALUES('Table'[Name]))

 

 

vyohuamsft_0-1713767755543.png

 

And then compare it with the original table, and return a blank if no combination exists in the original table.

 

Column = LOOKUPVALUE('Table'[Value],
'Table'[Name],'Table 2'[Name],
'Table'[Cat],'Table 2'[Cat]
)

 

vyohuamsft_1-1713767823831.png

 

 

In the Table visual, if the number in a column is empty, it will automatically aggregate, and if you want to show white space in the Table visual, you need to put the DAX Measure with data into the view to show the previous white space

 

Measure = IF(MAX('Table 2'[Column]) = BLANK(),0,MAX('Table 2'[Column]))

 

 

 

My preview like this:

vyohuamsft_0-1713768417848.png

 

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

6 REPLIES 6
v-yohua-msft
Community Support
Community Support

Hi, @rob_vander2 

Thanks for the reply from @SuperUser/@NormalUser, please allow me to provide another insight:

You can create a new table, use the crossjoin function 

 

Table 2 = CROSSJOIN(VALUES('Table'[Cat]),VALUES('Table'[Name]))

 

 

vyohuamsft_0-1713767755543.png

 

And then compare it with the original table, and return a blank if no combination exists in the original table.

 

Column = LOOKUPVALUE('Table'[Value],
'Table'[Name],'Table 2'[Name],
'Table'[Cat],'Table 2'[Cat]
)

 

vyohuamsft_1-1713767823831.png

 

 

In the Table visual, if the number in a column is empty, it will automatically aggregate, and if you want to show white space in the Table visual, you need to put the DAX Measure with data into the view to show the previous white space

 

Measure = IF(MAX('Table 2'[Column]) = BLANK(),0,MAX('Table 2'[Column]))

 

 

 

My preview like this:

vyohuamsft_0-1713768417848.png

 

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

sjoerdvn
Super User
Super User

I used the html to get the table data, and added dimensions in power query (there are many different ways of doing this, depending on data source and personal preferences)
I have added the relationships and created measures for examples with either a "0" or a blank with an extra column.

sjoerdvn
Super User
Super User

If columns "Cat" and "Name" are in the same table, and they are used in the same (table) visual, Power BI will only show the existing combinations. To get around this, you need a dimension table for one or both columns. And even then, if all measures produce blanks, it supresses showing these rows. You would thean need a measure that returns for instance  "0" or "blank"

@sjoerdvn  Yes both are in same table and need to be used in same visual. Please advice. Could you share pbix file with solution?

Solution would depend on data source (file, SQL table etc.). Can you share what you have so far (with dummy data).

Hi, I already shared sample data in my post. Could you use to build solution?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors