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
gauravnarchal
Post Prodigy
Post Prodigy

How to find best month sales and month for each agent

Hello - How can I find which month was the best month (MMM-YY) and (Total) sales for each agent?

 

Total sales = Sale - Marketing Fee

 

Click here to download the PBIX file. Click Here 

 

I would like the result to be shown as below

 

gauravnarchal_0-1662999044627.png

Thanks

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @gauravnarchal ,

 

The calendar needs to contain all the dates in the fact table:

 

Calendar2 = 
ADDCOLUMNS (
    CALENDAR ( MIN ( 'Table 1'[InvoiceDate] ), MAX ( 'Table 1'[InvoiceDate] ) ),
    "MonthYear", FORMAT ( [Date], "mmmm yyyy" )
)

 

vcgaomsft_0-1663047946813.png

Relationships:

vcgaomsft_1-1663047991354.png

Total sales:

 

Total sales = 
SUM('Table 2'[Sale]) - SUM('Table 2'[Marketing Fee])

 

Then new a measure for filter:

 

Filter = 
VAR _agent =
    MAX ( 'Table 1'[Agent] )
VAR _monthyear =
    MAX ( 'Calendar2'[MonthYear] )
VAR _max =
    MAXX (
        FILTER (
            SUMMARIZE (
                ALLSELECTED ( 'Table 1' ),
                'Table 1'[Agent],
                'Calendar2'[MonthYear]
            ),
            'Table 1'[Agent] = _agent
        ),
        [Total sales]
    )
VAR _filter = IF([Total sales]<>BLANK()&&[Total sales]<>_max,0,1)
RETURN
    _filter

 

Result:

vcgaomsft_3-1663048246785.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @gauravnarchal ,

 

The calendar needs to contain all the dates in the fact table:

 

Calendar2 = 
ADDCOLUMNS (
    CALENDAR ( MIN ( 'Table 1'[InvoiceDate] ), MAX ( 'Table 1'[InvoiceDate] ) ),
    "MonthYear", FORMAT ( [Date], "mmmm yyyy" )
)

 

vcgaomsft_0-1663047946813.png

Relationships:

vcgaomsft_1-1663047991354.png

Total sales:

 

Total sales = 
SUM('Table 2'[Sale]) - SUM('Table 2'[Marketing Fee])

 

Then new a measure for filter:

 

Filter = 
VAR _agent =
    MAX ( 'Table 1'[Agent] )
VAR _monthyear =
    MAX ( 'Calendar2'[MonthYear] )
VAR _max =
    MAXX (
        FILTER (
            SUMMARIZE (
                ALLSELECTED ( 'Table 1' ),
                'Table 1'[Agent],
                'Calendar2'[MonthYear]
            ),
            'Table 1'[Agent] = _agent
        ),
        [Total sales]
    )
VAR _filter = IF([Total sales]<>BLANK()&&[Total sales]<>_max,0,1)
RETURN
    _filter

 

Result:

vcgaomsft_3-1663048246785.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

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.