Wednesday 18 July 2018

Top4 Items in a Sentence

Using the Superstore dataset, create a chart which finds your 4 top-selling SubCategories and returns them in a sentence as below.


"Your top-selling sub-category is (Top Sub-Category),next (2nd Sub-Category).. (3rd Sub-Category) and (4th Sub-Category)


Step1:-
Drag [Sub-Category] to the Rows shelf.
Step2:-
Create a calculation with following formula to find  top-selling sub-category and name the calculated field as [Top Sub-Category].

IF RANK(SUM([Sales])) = 1 THEN MIN([Sub-Category]) END

Drag the above calculated field into Label of the Marks Card.

This calculated Field  will return the name of the  sub-category for that row containing the sub-category.

Step3:-

To get sub-category in every row,create a calculated field with name [Top1] and 

with following formula.

WINDOW_MAX([Top Sub-Category])


Step4:-
Repeat steps 2 and 3 for 2nd,3rd and 4th best sub-categories.
The RANK for 2nd,3rd,4th Best Sub-Categories  should equal to 2,3,4 respectively, instead of 1.
Take WINDOW_MAX on 2nd,3rd,4th  Best Sub-Categories.
Name  final calcs as [Top2],[Top3] and [Top4].

Step5:-
Drag the [Top1],[Top2],[Top3],[Top4] Calc fields into the label of the marks card and remove remaining fields.
Step6:-
Edit the text in the following way.
Click the Text shelf and click the "..." to the right of the text. 



Step7:-

Right Click on  the Sub-Category on Rows Shelf and un-select "Show Header".

Step8:-
To Show in 1 sentence in a single row create a calculated field with the formula "INDEX()=1" ,Drag it into Filters and select "True".

Thanks Guru's,
Prazval.ks

DAX Time Intelligence Functions

   Thanks Guru's, Prazval.Ks