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
Thoms
Frequent Visitor

exact date of max of sum per day among the month

 

Dear friends,

 

Ran into an issue,

need to add visual column (red one) with date when was max in the month. is it possible? 

 

 

max in month by product = 

Measure 2 = var _table=CALCULATETABLE(SUMMARIZE('Table','Table'[city],'Table'[product #],'Table'[Month],'Table'[date],"_pcs",SUM('Table'[pcs])),ALL('Table'[date])) return
MAXX(_table,[_pcs])

(Thanx a lot to @

 

 

cityproduct #datepcssumup per daymax in month by product and cityexact date of max in month
Beijing123544January 01 201911117January 02 2019
Beijing123544January 01 2019101117January 02 2019
Beijing123544January 02 2019151717January 02 2019
Beijing123544January 02 201921717January 02 2019
Shanghai123544January 01 201931515January 01 2019
Shanghai123544January 01 2019121515January 01 2019
Shanghai123544January 02 2019121215January 01 2019
1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Thoms ,

 

Please refer to below measures:

sumup per day =
CALCULATE (
    SUM ( Test_6[pcs] ),
    ALLEXCEPT ( Test_6, Test_6[city], Test_6[product #], Test_6[date] )
)

max in month by product and city =
MAXX (
    FILTER (
        ALLSELECTED ( Test_6 ),
        Test_6[city] = SELECTEDVALUE ( Test_6[city] )
            && Test_6[product #] = SELECTEDVALUE ( Test_6[product #] )
            && Test_6[date].[Year] = YEAR ( SELECTEDVALUE ( Test_6[date] ) )
            && Test_6[date].[MonthNo] = MONTH ( SELECTEDVALUE ( Test_6[date] ) )
    ),
    [sumup per day]
)

exact date of max in month =
CALCULATE (
    SELECTEDVALUE ( Test_6[date] ),
    FILTER (
        ALLSELECTED ( Test_6 ),
        Test_6[city] = SELECTEDVALUE ( Test_6[city] )
            && Test_6[product #] = SELECTEDVALUE ( Test_6[product #] )
            && Test_6[date].[Year] = YEAR ( SELECTEDVALUE ( Test_6[date] ) )
            && Test_6[date].[MonthNo] = MONTH ( SELECTEDVALUE ( Test_6[date] ) )
            && [sumup per day] = [max in month by product and city]
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @Thoms ,

 

Please refer to below measures:

sumup per day =
CALCULATE (
    SUM ( Test_6[pcs] ),
    ALLEXCEPT ( Test_6, Test_6[city], Test_6[product #], Test_6[date] )
)

max in month by product and city =
MAXX (
    FILTER (
        ALLSELECTED ( Test_6 ),
        Test_6[city] = SELECTEDVALUE ( Test_6[city] )
            && Test_6[product #] = SELECTEDVALUE ( Test_6[product #] )
            && Test_6[date].[Year] = YEAR ( SELECTEDVALUE ( Test_6[date] ) )
            && Test_6[date].[MonthNo] = MONTH ( SELECTEDVALUE ( Test_6[date] ) )
    ),
    [sumup per day]
)

exact date of max in month =
CALCULATE (
    SELECTEDVALUE ( Test_6[date] ),
    FILTER (
        ALLSELECTED ( Test_6 ),
        Test_6[city] = SELECTEDVALUE ( Test_6[city] )
            && Test_6[product #] = SELECTEDVALUE ( Test_6[product #] )
            && Test_6[date].[Year] = YEAR ( SELECTEDVALUE ( Test_6[date] ) )
            && Test_6[date].[MonthNo] = MONTH ( SELECTEDVALUE ( Test_6[date] ) )
            && [sumup per day] = [max in month by product and city]
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Thoms

 

Perhaps something like;

Calculate(max('Table'[date]),filter('Table','Table'[date].[Month] = Table'[date].[Month] && 'Table'[date].[Year] = Table'[date].[Year]))

Thanx dear for the feedback!

 

Sorry, but i guess was not precise.

I need exact date of max value in month. So need reference to column "max in month by product and city", how to add it to the dax?

Anonymous
Not applicable

OK.

 

So something like;

 

Calculate(max('Table'[date]),filter('Table','Table'[max in month by product and city] = Table'[max in month by product and city]))

 

However if you have 2 cities with the same [max in month by product and city] that might not work. You could add more filter criteria if you want this to be specific to a city and/or product

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.

Top Solution Authors