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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
jayantkodwani
Microsoft Employee
Microsoft Employee

MAXIF CALCULATED COLUMN

I need to implement MAXIF as a calculated column. It is piece of cake in Excel as shows below but I am not able to get exact DAX formula in POWER BI.  

 

I have 3 columns and the MAXIF formula in Excel matches the ID as well as value column, the result is the max month where ID is same and value is "-1" (i.e. June for Id=101 AND May for id=201), 

 

In Power BI I have tried the below but it does not consider the ID at the row level and gives June for both the id's ( see PBI snapshot)  How can I achieve the results shown in Excel snaphsot but in PBI?

 

Max Month where ID is minus 1 = calculate(max(Test[Fiscal Month]),FILTER(Test,Test[ID]=Test[ID] && Test[Value] = -1))

 

 

Maxifs.JPGMaxifPowerBi.JPG

 

Here is the sample Data:

 

ID Fiscal Month Value Max Month where ID =1
101 4/1/2020 1 6/1/2020
101 6/1/2020 -1 6/1/2020
201 12/1/2019 1 5/1/2020
201 2/1/2020 -1 5/1/2020
201 2/1/2020 1 5/1/2020
201 5/1/2020 -1 5/1/2020

2 ACCEPTED SOLUTIONS

Hello @jayantkodwani ,

You can add an ALLEXCEPT() as shown below:

Column =
CALCULATE (
    MAX ( 'Table'[Fiscal Month] ),
    FILTER ( ALLEXCEPT ( 'Table', 'Table'[ID] ), 'Table'[Value] = -1 )
)

Best Regards,
Xue Ding
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

Hello @v-xuding-msft

here's my solution (see figure)

24-08-_2020_14-15-58.png

Max Month where ID is minus 1 = 
CALCULATE(
    MAX('Table'[Fiscal Month]),
    FILTER(
        ALLEXCEPT(
            'Table',
            'Table'[ID]
        ),
        'Table'[Value] = -1
    )
)

Greetings FrankAT

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@jayantkodwani - According to the Excel to DAX Translation reference: https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991

 

MAXIF found here:

https://community.powerbi.com/t5/Community-Blog/L-M-Excel-to-DAX-Translation/ba-p/1061081

 

The DAX equivalent is:

MAXX(FILTER(... && ...)...) or CALCULATE(MAX(),FILTER(... && ...))



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg, appreciate your timely response, While the list of Excel to DAX is highly beneficial, it does not work directly for me. If we look at the initial PBI snapshot, I already tried the DAX equivalent you mentioned but it was not working in the calculated column giving same month values for all the rows. The reason seems to be the query context. So, I finally solved it by a workaround

Step 1 - Created a Meaure

Max Measure.JPG


Step 2 - Created a calculated table to use the measure only with ID

Create New Table to use Measure.JPG


Step 3 - Used LOOKUPVALUE

Lookupvalue.JPG

Hello @jayantkodwani ,

You can add an ALLEXCEPT() as shown below:

Column =
CALCULATE (
    MAX ( 'Table'[Fiscal Month] ),
    FILTER ( ALLEXCEPT ( 'Table', 'Table'[ID] ), 'Table'[Value] = -1 )
)

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-xuding-msft

here's my solution (see figure)

24-08-_2020_14-15-58.png

Max Month where ID is minus 1 = 
CALCULATE(
    MAX('Table'[Fiscal Month]),
    FILTER(
        ALLEXCEPT(
            'Table',
            'Table'[ID]
        ),
        'Table'[Value] = -1
    )
)

Greetings FrankAT

Hi @FrankAT ,

 

Thanks for the solution. But, I'm not the questioner. And your formula is same as mine.🙂

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.