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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Garbo62
Helper III
Helper III

Return Week number of Max Events

Hi, need help with a DAX Query I want to retune which week(s) the max hours occurs not all weeks for each course?

 

Weekly Course Hours Max = SUMMARIZECOLUMNS('Weekly Course Hours'[Course (Weekly)],'Weekly Course Hours'[Week No],"Max Week" , MAX('Weekly Course Hours'[Hours Per Week]))
 
Garbo62_0-1685104612923.png

 

1 ACCEPTED SOLUTION

or you plot the course column with two measures like:

_WeekMax = MAX(data[WeekMax])
_WeekNo = 
MAXX(
    TOPN(
        1,
        data,
        data[WeekMax]
    ),
    data[WeekNo]
)

it worked like:

FreemanZ_2-1685153590869.png

View solution in original post

4 REPLIES 4
Garbo62
Helper III
Helper III

Thanks, it is common thet the max week occurs more then once, is there a war to expemf to reuurm them all

i.e. Course A may have a max hours in week 3,7 and week 10.

Garbo62
Helper III
Helper III

Hi, Thanks, nearly right

It is returning the hours for the max week, but it is returning the last (Max) value for Week No. and not the weeks this values occur on i,e, the first course has 30 weeks of data, so it is returning 30 and not weeks 11, 12, 14 14 & 15

 

Garbo62_0-1685184203430.png

 

Garbo62_1-1685184432673.png

 

 

FreemanZ
Super User
Super User

hi @Garbo62 

not sure if i fully get you, supposing you have a data table like:

FreemanZ_0-1685153234523.png

try to create a calculated table like:

Table = 
ADDCOLUMNS(
    ADDCOLUMNS(
        VALUES(data[course]),
        "WeekMax",
        CALCULATE(MAX(data[WeekMax]))
    ),
    "WeekNo",
    CALCULATE(MAX(data[WeekNo]))
)

it worked like:

FreemanZ_1-1685153287439.png

 

or you plot the course column with two measures like:

_WeekMax = MAX(data[WeekMax])
_WeekNo = 
MAXX(
    TOPN(
        1,
        data,
        data[WeekMax]
    ),
    data[WeekNo]
)

it worked like:

FreemanZ_2-1685153590869.png

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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