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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AkameNoGamma
Frequent Visitor

Formula for Column Based on Filters

I need help with the column formula to get the department transfer details as I'm out of options and ideas.

 

the idea is that I have a set of employee lists (which is book2 for example) and then I will add a column in powerbi to generate the department of the employee on a giver fiscal year and month.

then I also have the department transfer report which displays when the employee got transferred to a new department (which is book1 in the screenshot).

 

for example, Arnel Fabay's Department last January 2024 was in Business Finance, then in Feb 2023, he got transferred to Accounting Ops. In powerbi, if I change the filters for Fiscal Year and Month, the Department Transfer in Book2 will change based on the filters. if there were no department changes happened, then Department Transfer will use the existing department of the employee, but if there was a change like with Arnel Fabay, then his department will show as "Accounting Ops" starting Feb 2024 and onwards. i hope I make sense.

 

Screenshot 2024-02-22 165913.png

1 ACCEPTED SOLUTION

Hi @AkameNoGamma 

 

The currentdate is to get the value of the row separately but not the really current date.

Just like this:

vzhengdxumsft_0-1709170888067.png

Certainly the Slicer can not affect the table view, but what i used is the table visual in the report view.

vzhengdxumsft_1-1709171011555.png

At last, the calender date is created for your reference, you can create a new reference table.

 

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Zhengdong Xu
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

4 REPLIES 4
v-zhengdxu-msft
Community Support
Community Support

Hi @AkameNoGamma 

 

Please try this:

First of all, I create a set of sample:

the book2:

vzhengdxumsft_0-1708653429231.png

Book 1:
vzhengdxumsft_1-1708653439557.png

Then add a calender table as a reference.

The Book1 and Book2 should be linked as an one-to-one relationship:

vzhengdxumsft_2-1708653624169.png

Then add a measure:

CurrentDepartment =
VAR _currentDate =
    MAX ( 'Table'[Date] )
RETURN
    IF (
        _currentDate < MAX ( 'book1'[Effective Start Date] ),
        SELECTEDVALUE ( book1[Previous Department] ),
        SELECTEDVALUE ( book1[New Department] )
    )

Create a table and a slicer:

vzhengdxumsft_3-1708653698658.pngvzhengdxumsft_4-1708653715492.png

The result is as follow:

vzhengdxumsft_5-1708653740972.pngvzhengdxumsft_6-1708653767450.pngvzhengdxumsft_7-1708653777806.png

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Thank you for replying to my post. I dont think "current" date will work as i need the column to reflect the new or previous department based on my slicers. and while researching, it seems that the slicers that i have will not affect the table view

Hi @AkameNoGamma 

 

The currentdate is to get the value of the row separately but not the really current date.

Just like this:

vzhengdxumsft_0-1709170888067.png

Certainly the Slicer can not affect the table view, but what i used is the table visual in the report view.

vzhengdxumsft_1-1709171011555.png

At last, the calender date is created for your reference, you can create a new reference table.

 

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

and to add, i'm actually looking for a formula that dynamically changed regardless of the year and month slicers that i selected.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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