Forum Discussion

danb's avatar
danb
Resolver I
8 years ago
Solved

Plot Store with Max Sales over Time Period

Hi Gurus! 

 

I have a list of stores and plates that I want to chart out. The issue is I am trying to figure out how to plot (on a line graph) the store that has the most amount of sales over the time period. I tried Calculate/MAX however it looks like it is only plotting the highest value per day. 

 

The goal is to have (depending on the slicer/plate selected) have the chart show the store that sold the most during the whole time period. 

 

An example result would be for plate "a", i would expect to have store #5 plotted. For plate "b" it would be store #3. 

 

Here is the datatable i am working with:

Store #PlateDateQuantity Sold
1a7/1/201844
1b7/1/201837
1c7/1/201850
1a7/2/201838
1b7/2/201843
1c7/2/201857
1a7/3/201835
1b7/3/201867
1c7/3/201888
1a7/4/201880
1b7/4/201859
1c7/4/201827
1a7/5/201870
1b7/5/201852
1c7/5/201825
1a7/6/201876
1b7/6/201867
1c7/6/201836
1a7/7/201885
1b7/7/201835
1c7/7/201831
1a7/8/201841
1b7/8/201843
1c7/8/201840
1a7/9/201841
1b7/9/201846
1c7/9/201868
2a7/1/201837
2b7/1/201823
2c7/1/201816
2a7/2/201881
2b7/2/201892
2c7/2/201877
2a7/3/201872
2b7/3/201825
2c7/3/201844
2a7/4/201812
2b7/4/201822
2c7/4/201842
2a7/5/201891
2b7/5/201863
2c7/5/201893
2a7/6/201816
2b7/6/201882
2c7/6/201843
2a7/7/201821
2b7/7/201876
2c7/7/201867
2a7/8/201886
2b7/8/201836
2c7/8/201837
2a7/9/201898
2b7/9/201890
2c7/9/201875
3a7/1/201849
3b7/1/201866
3c7/1/201817
3a7/2/201892
3b7/2/201833
3c7/2/201871
3a7/3/201840
3b7/3/201884
3c7/3/201815
3a7/4/201882
3b7/4/201874
3c7/4/201822
3a7/5/201825
3b7/5/201892
3c7/5/201882
3a7/6/201834
3b7/6/201825
3c7/6/201857
3a7/7/201845
3b7/7/201845
3c7/7/201820
3a7/8/201890
3b7/8/201860
3c7/8/201874
3a7/9/201830
3b7/9/201896
3c7/9/201816
4a7/1/201835
4b7/1/201879
4c7/1/201895
4a7/2/201856
4b7/2/201870
4c7/2/201860
4a7/3/201814
4b7/3/201819
4c7/3/201877
4a7/4/201849
4b7/4/201874
4c7/4/201877
4a7/5/201882
4b7/5/201877
4c7/5/201815
4a7/6/201848
4b7/6/201843
4c7/6/201857
4a7/7/201847
4b7/7/201816
4c7/7/201842
4a7/8/201816
4b7/8/201873
4c7/8/201852
4a7/9/201898
4b7/9/201847
4c7/9/201864
5a7/1/201851
5b7/1/201837
5c7/1/201857
5a7/2/201888
5b7/2/201886
5c7/2/201891
5a7/3/201867
5b7/3/201858
5c7/3/201846
5a7/4/201875
5b7/4/201821
5c7/4/201827
5a7/5/201851
5b7/5/201887
5c7/5/201812
5a7/6/201862
5b7/6/201872
5c7/6/201833
5a7/7/201899
5b7/7/201884
5c7/7/201840
5a7/8/201874
5b7/8/201815
5c7/8/201875
5a7/9/201860
5b7/9/201851
5c7/9/201812

 

 

  • Hi danb,

     

    1. Create the two measures:

     

     

    the_store_for_max_sales =
    VAR maxstore =
        CALCULATE (
            MAX ( 'Table'[Store #] ),
            FILTER ( 'Table', 'Table'[Quantity Sold] = MAX ( 'Table'[Quantity Sold] ) )
        )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Quantity Sold] ),
            FILTER ( 'Table', 'Table'[Store #] = maxstore )
        )
    
    Measure 2 =
    VAR temp =
        MAXX (
            TOPN (
                1,
                SUMMARIZE (
                    ALLSELECTED ( 'Table' ),
                    [Plate],
                    [Store #],
                    "Total", SUM ( [Quantity Sold] )
                ),
                [Total], DESC
            ),
            [Store #]
        )
    RETURN
        IF ( MAX ( 'Table'[Store #] ) = temp, "Y", "N" )
    

    2.  Drag the measure2 to visual level filter like below.

     

     

    For more details, you could have a reference of the attachment.

     

    Best  Regards,

    Cherry

5 Replies

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi danb,

     

    If I understand your requirement correctly that you want to get the output like below?

     

     

    If it is, you could refer to the measure below.

     

    the_store_for_max_sales =
    CALCULATE (
        MAX ( 'Table'[Store #] ),
        FILTER ( 'Table', 'Table'[Quantity Sold] = MAX ( 'Table'[Quantity Sold] ) )
    )
    

    Then you could create the line chart with the Date and the measure.

     

    Best Regards,

    Cherry

    • danb's avatar
      danb
      Resolver I

      v-piga-msft

      Cherry,

      I am actually trying to plot the actual sales of whatever store sold the most for that selected plate. For example if I was looking at plate "A" i would want the max chart to plot the daily sales from only Store #5 because it sold the most of all of the stores from that time period. 

       

      Sorry for the un-clarity on the original post. 

       

      Thank you for you help in this!

       

      Dan

      • v-piga-msft's avatar
        v-piga-msft
        Resident Rockstar

        Hi danb,

         

        1. Create the two measures:

         

         

        the_store_for_max_sales =
        VAR maxstore =
            CALCULATE (
                MAX ( 'Table'[Store #] ),
                FILTER ( 'Table', 'Table'[Quantity Sold] = MAX ( 'Table'[Quantity Sold] ) )
            )
        RETURN
            CALCULATE (
                SUM ( 'Table'[Quantity Sold] ),
                FILTER ( 'Table', 'Table'[Store #] = maxstore )
            )
        
        Measure 2 =
        VAR temp =
            MAXX (
                TOPN (
                    1,
                    SUMMARIZE (
                        ALLSELECTED ( 'Table' ),
                        [Plate],
                        [Store #],
                        "Total", SUM ( [Quantity Sold] )
                    ),
                    [Total], DESC
                ),
                [Store #]
            )
        RETURN
            IF ( MAX ( 'Table'[Store #] ) = temp, "Y", "N" )
        

        2.  Drag the measure2 to visual level filter like below.

         

         

        For more details, you could have a reference of the attachment.

         

        Best  Regards,

        Cherry