Forum Discussion

TCatron18's avatar
TCatron18
Helper II
1 year ago
Solved

If Statement in Measure

Hello!

 

I've looked around but not finding a solution that works for my situation. 

 

I am trying to add a row into a matrix that has a static value for a specific column. Below is the current statement I have created; however, I am getting an error on the 'Awards'[Sender's Sr Business Unit] section, and not sure what I need to do. 

 

Total Emp Count =
VAR MinDate =
FIRSTDATE ( 'Period Table'[Date] )
VAR MaxDate =
LASTDATE ( 'Period Table'[Date] )
VAR SysGen = 1
VAR EmpCount =
CALCULATE (
COUNTROWS ( 'UPH Employee Census' ),
('UPH Employee Census'[HRDATE] >= MinDate
&& 'UPH Employee Census'[HRDATE] <= MaxDate)
)
Return
IF( 'Awards'[Sender's Sr Business Unit] = "xSystem Generated", SysGen, EmpCount - [Total Mgr Count] )
 
My expected result is to have:
Sr Business UnitTotal Emp Count
A[count]
B[count]
C[count]
xSystem Generated1
 
Thank you in advance for any assistance you can provide!
  • Add selectedvalue()

     

    IF( selectedvalue('Awards'[Sender's Sr Business Unit] ) = "xSystem Generated",

6 Replies

  • Deku's avatar
    Deku
    Super User

    Add selectedvalue()

     

    IF( selectedvalue('Awards'[Sender's Sr Business Unit] ) = "xSystem Generated",

      • Deku's avatar
        Deku
        Super User

        The = "xSystemGenerate" should be outside of the selectedvalue brackets

  • Well that did help get it to stop erroring; however, I'm still having an issue getting to actually add that row to my matrix. 

     

    Edit: I might have figured it out. Hopefully ğŸ™‚

  • Completely agree with Deku.  You are getting the error because currently you are referencing the entire column of values of the 'Awards'[Sender's Sr Business) Unit] column.  Adding SelectedValue() around the column gives you a single value to evaluate in the statement within the filter context.  This has happened to me so many times 🙂