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

Top 1 Of Max

Hello,

 

I am a newbie to PowerBI trying to grasp some fundamental concepts.I have a sample dataset(screenshot and file attached) with the post.

 

What I am trying to do here is to get the Top1 of the Max Total for the branches.The sample dataset has only one branch there can be n number of such branches.The Dax query should return the row that I have highlighted in the screesnshot.It is similar to using Row Number parition in SQLData.png

 

Data : Sample Data

 

 

2 ACCEPTED SOLUTIONS

@M2M

 

If you have many branches..then may be you can use this

 

New Table =
ADDCOLUMNS (
    SUMMARIZE ( Sample1, Sample1[Branches], "Max Total", MAX ( Sample1[Total] ) ),
    "Max Book Resale", CALCULATE (
        MAX ( Sample1[Book Resale - SALE] ),
        Sample1[Total] = EARLIER ( [Max Total] )
    ),
    "Inside Sales", CALCULATE (
        MAX ( Sample1[Inside Sales.Inside Sales Name] ),
        Sample1[Total] = EARLIER ( [Max Total] )
    ),
    "Manufacturer", CALCULATE (
        MAX ( Sample1[Manufacturer Inside Sales Person] ),
        Sample1[Total] = EARLIER ( [Max Total] )
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

Hi @M2M

 

This is an even better way of achieving the results

 

Table =
GENERATE (
    SELECTCOLUMNS (
        SUMMARIZE ( Sample1, Sample1[Branches] ),
        "MyBranches", [Branches]
    ),
    CALCULATETABLE (
        TOPN ( 1, Sample1, Sample1[Total], DESC, Sample1[Book Resale - SALE], DESC )
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

5 REPLIES 5
M2M
Frequent Visitor

Please any help on this ?

Hi @M2M,

 

Did you mean this?

 

Create a new calculated table with DAX TOPN() function.

 

Top 1 =
TOPN (
    1,
    'sample',
    'sample'[Total], DESC,
    'sample'[Book Resale - SALE], DESC,
    'sample'[Booked Manufacturer Inside Sales Person], DESC
)

6.PNG

 

Thanks,
Xi Jin.

@M2M

 

If you have many branches..then may be you can use this

 

New Table =
ADDCOLUMNS (
    SUMMARIZE ( Sample1, Sample1[Branches], "Max Total", MAX ( Sample1[Total] ) ),
    "Max Book Resale", CALCULATE (
        MAX ( Sample1[Book Resale - SALE] ),
        Sample1[Total] = EARLIER ( [Max Total] )
    ),
    "Inside Sales", CALCULATE (
        MAX ( Sample1[Inside Sales.Inside Sales Name] ),
        Sample1[Total] = EARLIER ( [Max Total] )
    ),
    "Manufacturer", CALCULATE (
        MAX ( Sample1[Manufacturer Inside Sales Person] ),
        Sample1[Total] = EARLIER ( [Max Total] )
    )
)

Regards
Zubair

Please try my custom visuals

Thanks Zubair.I had to tweak your solution a little bit to get it working, Smiley Happy

Hi @M2M

 

This is an even better way of achieving the results

 

Table =
GENERATE (
    SELECTCOLUMNS (
        SUMMARIZE ( Sample1, Sample1[Branches] ),
        "MyBranches", [Branches]
    ),
    CALCULATETABLE (
        TOPN ( 1, Sample1, Sample1[Total], DESC, Sample1[Book Resale - SALE], DESC )
    )
)

Regards
Zubair

Please try my custom visuals

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.