Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have below tables in a tabular data base, and I want to get the max favorite price range for each member.

DimMember(MemberKey int,MemberName varchar(50)
DimPriceRange(PriceRangeKey,PriceRangeValue varchanr(50))
FactOrders(FactOrderKey int,MemberKey int,PriceRangeKey)

The DAX query I tried to use is below, but it emits an error when execution, can someone help me out, thanks!

the error states cannot determine a table that contains [OrderCount]

evaluate
	summarize (
		summarize (
			factorders,
			factorders[memberkey],
			factorders[pricerangekey],
			"OrderCount",countrows(factorders)
		),
		factorders[memberkey],
		"MaxOrderCount",Max([OrderCount])
	)


The interesting thing is that below DAX query can be executed if don't put [OrderCount] in the Max function.

evaluate
	summarize (
		summarize (
			factorders,
			factorders[memberkey],
			factorders[pricerangekey],
			"OrderCount",countrows(factorders)
		),
		factorders[memberkey],
		[OrderCount]
	)


below is the execution result:
VB
FactOrders[MemberKey]   [OrderCount]
1   1
3   2
2   2
3   1
1   2
2   1


what I want is below, which only returns the max [OrderCount] for each member.
VB
FactOrders[MemberKey]   [OrderCount]
3   2
2   2
1   2
Posted
Updated 14-Aug-15 13:56pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900