Forum Discussion

PowerUP200's avatar
PowerUP200
Frequent Visitor
1 year ago
Solved

Measure to return same value over multiple rows in table visual

I'm trying to create a measure to use in a table visual. 

 

I have the below table which lists 2 employee's history. I want to add two measure which list what their Acting and Substantive classifications are depending on what date is selected on an separate slicer based on a Date table. 

 

PersonStart dateEnd DateClassificationAreaPlacement Type
A1-Jul-241-Aug-246Stats TeamActing
A16-May-2331-Dec-995Data TeamSubstantive
A1-Jan-2315-May-234Data TeamSubstantive
B1-Jan-2431-Dec-994Stats TeamSubstantive

 

The way the placements work is at any one time, each employee by default has only one substantive employment placement. However, they can sometimes act up in senior positions, in which case the system assigns them a second placement, 'Acting'. At these times, they have 2 active placements, until their acting period ends. 

 

So for example, if I selected the date 1 December 2023, only one row of data would return a value as person A was the only one working, and we would only get a substantive value as A was not acting. 

PersonStart dateEnd DateClassificationAreaPlacement TypeSubstantive Placement ClassificationActing Placement Classification
A1-Jul-241-Aug-246Stats TeamActing  
A16-May-2331-Dec-995Data TeamSubstantive5 
A1-Jan-2315-May-234Data TeamSubstantive  
B1-Jan-2431-Dec-994Stats TeamSubstantive  

 

However, if I selected the date 1 July 2024, we would get 3 rows of data. However, this is where my second requirement comes in:

 

Is it possible, where someone is acting, to allocate the same classifications across both rows? I've tried with various ALL and REMOVEFILTER combinations but I can't seem to break the row context properly to apply it to both rows. 

 

PersonStart dateEnd DateClassificationAreaPlacement TypeSubstantive Placement ClassificationActing Placement Classification
A1-Jul-241-Aug-246Stats TeamActing56
A16-May-2331-Dec-995Data TeamSubstantive56
A1-Jan-2315-May-234Data TeamSubstantive  
B1-Jan-2431-Dec-994Stats TeamSubstantive4 

 

Thanks in advance for any guidance. Happy to provide more info if needed.

4 Replies

  • Aburar_123's avatar
    Aburar_123
    Solution Supplier

    Hi PowerUP200 ,

    Could you pls provide more clarity on your existing table structure and the expected result that you want to see and what result that you have derived so far.

  • Hi PowerUP200 ,

     

    To show the same value (e.g., classification) across multiple rows for each employee and date selection, you need to calculate the value ignoring row context and just based on person and selected date.

     

    You can use a measure like this:

    SubstantivePlacement =
    VAR selDate = SELECTEDVALUE('Date'[Date])
    VAR selPerson = SELECTEDVALUE('YourTable'[Person])
    RETURN
    CALCULATE(
        MAX('YourTable'[Classification]),
        FILTER(
            ALL('YourTable'),
            'YourTable'[Person] = selPerson &&
            'YourTable'[Placement Type] = "Substantive" &&
            'YourTable'[PersonStart date] <= selDate &&
            'YourTable'[End Date] >= selDate
        )
    )
    

     

    And do the same for "Acting" by changing the placement type in the filter.

     

  • This is the result I got, I have to say it was tough to get it (so thank you!)

     

     

     

    I just left blank the end date instead of putting year 2099 for best practice (we can fix this to work also with 2099 in case you cannot remove that value)

     

    If that is what you were looking for, here is my solution (pbix)

     

    https://drive.google.com/drive/folders/1Rmd2KqfCMOw-N3o190NzlDjP_7psU_jV?usp=sharing

     

    If this helped, please consider giving kudos and mark as a solution

    me in replies or I'll lose your thread

    Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

    Consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI

    • PowerUP200's avatar
      PowerUP200
      Frequent Visitor

      Thanks FBergamaschi, worked perfectly! The 2099 is unfortunately a quirk of the system, but I got your solution to work with it just fine.