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
ihungko
Frequent Visitor

Help Needed: SEARCH within SUMMARIZECOLUMNS

Hi everyone, I'm hoping someone can help.

 

I had a few tables consisted of million lines. Example below:

Table 1

AccountDeal IDTypeProduction YearShip Year
AAA25654Sell-to20232023
BBB21681Sell-through20222022
CCC33547Design20232023
AAA22258Sell-to20212023
BBB35498Sell-to20232023
CCC11568Partner-led20222022
DDD11359Sell-through20232023
DDD38794Design20212023
AAA33545Sell-through20232024

 

Table 2

Deal IDNewSegmentCo-Work
25654TRUEXYes
21681FALSEYNo
33547TRUEXYes
22258TRUEZYes
35498FALSEXYes
11568TRUEYNo
11359FALSEYNo
38794FALSEYYes
33545TRUEZNo

 

Now I wanted to summarize the column [Deal ID] and also add new KPI columns based on a few conditions: 

I want to add columns to category the KPI each deal fulfiled, and an aggregated column as well.

For KPI-A, conditions would go as

    {[Type] contains "sell-to" || "sell-through" } &&

    [Segment] = "X"  &&

    [Ship Year] = 2023  &&

    [Co-Work] = "Yes" &&

    [New] = TRUE

 

For KPI-B, conditions are:

    [Type] contains "Design" &&

    [Production Year] = 2022 || 2023   &&

    [Co-Work] = No

 

The desired outcome would be as follow:

Deal IDKPI-AKPI-BKPI Concatenated
2565410KPI-A
2168111KPI-A, KPI-B
3354701KPI-B
2225810KPI-A
3549811KPI-A, KPI-B
1156801KPI-B
1135901KPI-B
3879411KPI-A, KPI-B
3354500 

 

The DAX code I used right now is as follow:

 

EVALUATE

SUMMARIZECOLUMNS(

	'Table1'[Deal ID],
	
	KEEPFILTERS( TREATAS({2023}, 'Table 1'[Ship Year])),
	
	"KPI-A", IF(
			OR(SEARCH("Sell-to", 'Table 1'[Type],1,0)>0,
				SEARCH("Sell-through",'Table 1'[Type],1,0)>0) &&
			
			SEARCH("X", 'Table 2'[Segment],1,0)>0 &&
			SEARCH("Yes",'Table 2'[Co-Work],1,0)>0 &&
			'Table 2'[NEW] = TRUE,
			
			"1", "0"),
			
	"KPI-B", IF(
			SEARCH("Design", 'Table 1'[Type],1,0)>0 &&
			[Production Year] IN {2022,2023} &&
			SEARCH("No",'Table 2'[Co-Work],1,0)>0,
			
			"1", "0")
			
	"KPI Concatenated", COMBINEVALUES( ", ", [KPI-A], [KPI-B])
	
	)

 

 

 

However, it gave me the error message "A single value for column xxx in table xxx cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregator such as min, max, count, or sum to get a single result. "  It seems the problem is located from the line where the code written after "KPI-A", IF( " 

 

I tried to use COUNTROWS(FILTER( xxx, CONTAINSSTRING(xxx,xxx)))>0 but when it comes to multiple OR and AND conditions, it gave me the same error.

 

Can anyone kindly help me? Thanks!

2 ACCEPTED SOLUTIONS
ERD
Super User
Super User

Hi @ihungko ,

You need to double check your conditions and the result you want to achieve.

ERD_0-1690397199904.png

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

Yes,

ERD_0-1690436717449.png

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

3 REPLIES 3
ERD
Super User
Super User

Hi @ihungko ,

You need to double check your conditions and the result you want to achieve.

ERD_0-1690397199904.png

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

ihungko
Frequent Visitor

Thank you so much, ERD. 

 

By the way, if one of my condition would be that check if rows in a certain column contains *keywords, how should I write the DAX? 

Can I use the following DAX along with other && ||  conditions?

 CONTAINSSTRING( SELECTEDVALUE( [Column] ), "*Keywords") = TRUE 

 

 

Yes,

ERD_0-1690436717449.png

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

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