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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply

IF statement measure

Hi everyone, 

 

I can't seem to get this to work, I would like to get a measure what takes the Average PPS from my table, depending on certain conditions. 

 

ruesaint_denis_0-1651592515063.png

 

These are the columns I'd like to work with. I'd like to write a meaure that takes this logic:

 

If ['Is Active']=True, take value of Average PPS, 

else if ['Company Status']=Open && Average PPS isnotblank, take the Average PPS when MAX['Updated At'], 

else "Please Check" 

 

I'm trying to create a matrix that has the Company ID as the rows, and this measure is one of the columns. 

Company ID does repeat, there shouldn't be more than 1 row for a company ID when ['Is Active']=True though.
I'm essentially trying to filter/manipulate which row to take for the Company ID's Average PPS. I don't really need to "calculate' anything, more than just filter. 

 

Thank you for the help!! 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ruesaint_denis ,

 

I create a sample with data from your screenshot to have a test.

Measure:

 

Measure = 
VAR _TRUE_AVG = CALCULATE(SUM('Table'[Average PPS]),'Table'[Is Active] = TRUE())
VAR _Active_list = CALCULATETABLE(VALUES('Table'[Is Active]),ALLEXCEPT('Table','Table'[Company Id]))
VAR _Status_list = CALCULATETABLE(VALUES('Table'[Company Status]),ALLEXCEPT('Table','Table'[Company Id]))
VAR _MAXDATE = CALCULATE(MAX('Table'[Updated At]),FILTER(ALLEXCEPT('Table','Table'[Company Id]),'Table'[Company Status] = "Open"))
VAR _OPEN_AVG = CALCULATE(SUM('Table'[Average PPS]),FILTER( ALLEXCEPT('Table','Table'[Company Id]), 'Table'[Updated At] = _MAXDATE))
RETURN
IF(TRUE() in _Active_list,_TRUE_AVG, IF("Open" in _Status_list && _OPEN_AVG<>BLANK(),_OPEN_AVG,"Please Check"))

 

Result is as below.

RicoZhou_1-1651825697555.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @ruesaint_denis ,

 

I create a sample with data from your screenshot to have a test.

Measure:

 

Measure = 
VAR _TRUE_AVG = CALCULATE(SUM('Table'[Average PPS]),'Table'[Is Active] = TRUE())
VAR _Active_list = CALCULATETABLE(VALUES('Table'[Is Active]),ALLEXCEPT('Table','Table'[Company Id]))
VAR _Status_list = CALCULATETABLE(VALUES('Table'[Company Status]),ALLEXCEPT('Table','Table'[Company Id]))
VAR _MAXDATE = CALCULATE(MAX('Table'[Updated At]),FILTER(ALLEXCEPT('Table','Table'[Company Id]),'Table'[Company Status] = "Open"))
VAR _OPEN_AVG = CALCULATE(SUM('Table'[Average PPS]),FILTER( ALLEXCEPT('Table','Table'[Company Id]), 'Table'[Updated At] = _MAXDATE))
RETURN
IF(TRUE() in _Active_list,_TRUE_AVG, IF("Open" in _Status_list && _OPEN_AVG<>BLANK(),_OPEN_AVG,"Please Check"))

 

Result is as below.

RicoZhou_1-1651825697555.png

 

Best Regards,
Rico Zhou

 

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

SpartaBI
Community Champion
Community Champion

@ruesaint_denis can you share a sample data in copy paste here and the desired result and logic (in words) for that result (the visual).

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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