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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
AllanBerces
Post Prodigy
Post Prodigy

Max number and other to Null or 0

Hi good day can anyone help me edit my calculated column, what i required on the new column is will show only the max number per week and the other will show null or 0. pls note i have multiple location

CountMAX/Week/Location =
VAR _currentWeek = 'Table'[Week No:]
VAR _currentCode = 'Table'[Location]
VAR _DirecIndirect = 'Table'[Direct/InDirect]
RETURN
    CALCULATE (
        MAX ( 'Table'[Count Direct/inDirect/Location] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Week No:] = _currentWeek &&
            'Table'[Location] = _currentCode &&
            'Table'[Direct/InDirect] = _DirecIndirect
        )
    )
AllanBerces_1-1771322778493.png

DESIRED OUTPUT

AllanBerces_2-1771322834327.png
DateBP'sLocationDirect/InDirectWeek No:Count Direct/inDirect/LocationCountMAX/Week/Location
2/11/2026MechNorthInDirect712null
2/11/2026MechNorthInDirect712null
2/11/2026MechNorthDirect712null
2/11/2026MechNorthDirect712null
2/11/2026MechNorthDirect712null
2/11/2026MechNorthDirect712null
2/11/2026MechNorthInDirect712null
2/11/2026MechNorthInDirect712null
2/11/2026MechNorthDirect712null
2/11/2026MechNorthDirect712null
2/11/2026MechNorthDirect712null
2/11/2026MechNorthDirect712null
2/12/2026MechNorthInDirect72323
2/12/2026MechNorthInDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthInDirect72323
2/12/2026CivilNorthInDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026CivilNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/12/2026ElecNorthDirect72323
2/13/2026ElecNorthInDirect713null
2/13/2026ElecNorthInDirect713null
2/13/2026ElecNorthInDirect713null
2/13/2026ElecNorthInDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null
2/13/2026ElecNorthDirect713null

 

2 ACCEPTED SOLUTIONS
cengizhanarslan
Super User
Super User

Please try the measure below:

CountMAX =
VAR _maxCnt =
    CALCULATE(
        MAX('Table'[Count Direct/inDirect/Location]),
        ALL('Table')
    )
RETURN
IF(
    'Table'[Count Direct/inDirect/Location] = _maxCnt,
    'Table'[Count Direct/inDirect/Location],
    BLANK()   -- or 0
)
_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

Hi @AllanBerces 

Try this:

CountMAX/Week/Location Calc Column = 
VAR _currentWeek = 'Table'[Week No:]
VAR _currentCode = 'Table'[Location]
VAR _DirecIndirect = 'Table'[Direct/InDirect]
VAR _FilteredTable =
    FILTER (
        'Table',
        'Table'[Week No:] = _currentWeek && 'Table'[Location] = _currentCode
            && 'Table'[Direct/InDirect] = _DirecIndirect
    )
RETURN
    IF (
        MAXX ( _FilteredTable, [Count Direct/inDirect/Location] ) = 'Table'[Count Direct/inDirect/Location],
        'Table'[Count Direct/inDirect/Location]
    )

danextian_0-1771326413535.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
cengizhanarslan
Super User
Super User

Please try the measure below:

CountMAX =
VAR _maxCnt =
    CALCULATE(
        MAX('Table'[Count Direct/inDirect/Location]),
        ALL('Table')
    )
RETURN
IF(
    'Table'[Count Direct/inDirect/Location] = _maxCnt,
    'Table'[Count Direct/inDirect/Location],
    BLANK()   -- or 0
)
_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Hi @AllanBerces 

Try this:

CountMAX/Week/Location Calc Column = 
VAR _currentWeek = 'Table'[Week No:]
VAR _currentCode = 'Table'[Location]
VAR _DirecIndirect = 'Table'[Direct/InDirect]
VAR _FilteredTable =
    FILTER (
        'Table',
        'Table'[Week No:] = _currentWeek && 'Table'[Location] = _currentCode
            && 'Table'[Direct/InDirect] = _DirecIndirect
    )
RETURN
    IF (
        MAXX ( _FilteredTable, [Count Direct/inDirect/Location] ) = 'Table'[Count Direct/inDirect/Location],
        'Table'[Count Direct/inDirect/Location]
    )

danextian_0-1771326413535.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian @cengizhanarslan Thank you very much for the reply it work as i need

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.