Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
danb
Resolver I
Resolver I

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

 

 

1 ACCEPTED SOLUTION

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.

 

store .png

 

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

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @danb,

 

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

 

Untitled.png

 

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

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@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

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.

 

store .png

 

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

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-piga-msft

That works. Thank you so much! 

@v-piga-msft - one last question, I am trying to flip it now and identify the Minimum sales store. Was thinking it was as simple as changing the MAXs to MINs and flipping the "DESC" to "ASC" in Measure2 however that is not working. Any recommendations? 

 

Dan

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.