2016-09-11 1 views
-1
How to write the DAX query for top n records and rest of records should be others? 

Example:- 

Table name sample 

col1  col2 
-------------- 
a  10 
b  20 
c  30 
d  40 
e  50 
f  60 

I need output like top 3 records rest of should be "others" 
like 
     col1  col2 
     ------------------- 
      a   10 
      b   20 
      c   30 
      others  150 
     ------------------- 

    Can anyone please help on this. Thanks in advance. 
+0

überprüfen tun könnte [diese Antwort] (http://stackoverflow.com/a/38089892/2647648) gab ich in einer sehr ähnlichen Frage. –

Antwort

0

Muss es dynamisch sein? wenn du es nicht den faulen Weg

evaluate ( 
summarize ( 
      sample, 
      if(pathcontains("a|b|c", sample[col1]) = false(), 
       "others", 
       sample[col1] 
       ), 
    "col2", sum(sample[col2]) 
      ) 
    ) 

order by 
sample[col1] 
Verwandte Themen