Forum Discussion

Lars_Denmark's avatar
Lars_Denmark
Frequent Visitor
2 years ago
Solved

Filter matrix by RankX measure

I have a sales table with customers and their revenue and date. For the X customers with the largest revenue measured over the whole year, I will create a matrix sorted by year, quarter and month,...
  • MFelix's avatar
    MFelix
    2 years ago

    Hi Lars_Denmark ,

     

    Create the following measures:

    Total Revenue for top customers = 
    VAR _temptable = ADDCOLUMNS(
    		VALUES('DummyData'[Customer]),
    		"rank", [Ranking Measure]
    	)
    	RETURN
    		SUMX(
    			FILTER(
    				'DummyData',
    				'DummyData'[Customer] IN SELECTCOLUMNS(
    					FILTER(
    						_temptable,
    						[rank] <> BLANK()
    					),
    					"d",
    					'DummyData'[Customer]
    				)
    			),
    			[Revenue Measure]
    		)
    
    % Over Total = DIVIDE([Total Revenue for top customers], [Revenue Measure])

    File attach.