Forum Discussion
danny3313
2 years agoRegular Visitor
Convert query to dax within table loop
Hi, I'm new to DAX... anyone can help me to convert this query to DAX.. i keep fail to get the result same as this query SELECT
DISTINCT TOP(10) [ITEM],
COUNT([ITEM]) AS 'count'
FROM
[TABLE_...
danny3313
2 years agoRegular Visitor
Hi talespin , thanks for help... and i trying to run your DAX but i got this error "Resource Governing: This query uses more memory than the configured limit"... have any faster way to run DAX?
My data have more than half of billion.
talespin
2 years agoSolution Sage
hi danny3313 ,
This one doesn't use Join, Again a calculated table.
Temp =
VAR _SummData =
ADDCOLUMNS(
ITEMS,
"HasBottle",
VAR _ReceiptNo = ITEMS[RECEIPT_NO]
RETURN CALCULATE( MAX(ITEMS[ITEM]), REMOVEFILTERS(ITEMS), ITEMS[ITEM] = "WATER BOTTLE 1L", ITEMS[RECEIPT_NO] = _ReceiptNo)
)
VAR _FilterTable = ADDCOLUMNS(
SUMMARIZE(
FILTER( _SummData, [HasBottle] = "WATER BOTTLE 1L" && [ITEM] <> "WATER BOTTLE 1L"),
[ITEM]
),
"CountItem",
VAR _Item = [ITEM]
RETURN COUNTX( FILTER( _SummData, [HasBottle] = "WATER BOTTLE 1L" && [ITEM] = _Item), [ITEM] )
)
RETURN TOPN(2, _FilterTable, [CountItem], DESC)
Replaced Distinct with MAX
I would advise doing this in Power Query.