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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
TK12345
Resolver I
Resolver I

How to find changes in postion with dax

Hi there,


I have an issue with the following. I need to know when the position of 1 employee has changed, based on the filter Month/Year. So when you see the picture, in 2019-06 till 2019-12 this employee has 1 function, but in 2021-02 he had another function so from that (month/year) the dif.functions column need to change to 2. So when I have a filter with (month/year) and I say 2019-8 it has to say 1 function. But changing the filter to 2021-03 it needs to say 2 because the filter changed.Err.PNGError.PNG

1 ACCEPTED SOLUTION

Hi  @TK12345 ,

 

Yes,using Power query can solve it and will be much easier.

First group rows as below:

vkellymsft_0-1634618555940.png

Then add an index column from 1 and expand the date column;

And you will see:

vkellymsft_1-1634618605004.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

 

View solution in original post

7 REPLIES 7
speedramps
Super User
Super User

Please cosnider this solution. Click the thumbs up icon for trying to helping you and then click SOLVED if it fixes your problems. Cheers !

 

All positions =

VAR mymonthyear = SELECTEDVALUE('HR Data'[MonthYear]) -- get the current row date
RETURN

CALCULATE( -- use calculate to override the row filters
DISTINCTCOUNT('HR Data'[Position]), -- get the number of positions
REMOVEFILTERS('HR Data'[Position]), -- remove the current row position filters because you want to count all positions
'HR Data'[MonthYear] <= mymonthyear -- only get postions up to an including the current row month
)

Hi there,
thanks for your help. Unfortunately it still does not work the way I would like to. When I make a matrix with the All positions filter it is still not 2. 

TK12345_0-1634542940511.png

As you can see in the picture, I need to show 2 when it changed the position. 
And when I filter on 2021-02 it also needs to show 2, but it show 1 as well.


TK12345_1-1634543118582.png

 

Hope you can help me, and thanks for your help last week.

Hi again TK12345

A slicer does what it is says on the tin.  It ‘slices’ your input data.

So you can’t slice a table by year 2021-02 and still include the other months.


A simple work around is to have 2 tables. Your master table and a picklist table with year/months with no relationship.

 

Then create 2 measure:-

 

All positions =

VAR mymonthyear = SELECTEDVALUE('HR Data'[MonthYear]) -- get the current row date

RETURN

 

CALCULATE( -- use calculate to override the row filters

DISTINCTCOUNT('HR Data'[Position]), -- get the number of positions

ALLEXCEPT('HR Data','HR Data'[Employee]),  -- remove all filters expcet the employee

'HR Data'[MonthYear] <= mymonthyear -- only get postions up to an including the current row month

)

 

 

All postitions with slicer =

VAR mymonthyear = SELECTEDVALUE('HR Data'[MonthYear]) -- get the current row date

VAR pickedmonth = SELECTEDVALUE('Date picklist'[MonthYear]) -- get the slicer date

RETURN

-- only return a result if the picklist date = the row date

IF(mymonthyear = pickedmonth, [All positions])

 

Click here to download an example 

 

PREVIEW
Please remember we are a community and dont get paid to give help, so please click the thumbs up for me helping you and the solved button if this fixes your problem.

Hi  @TK12345 ,

 

Create a column as below:

Column = RANKX(FILTER('Table','Table'[Employee]=EARLIER('Table'[Employee])),'Table'[Position],,ASC,Dense)

And you will see:

vkellymsft_0-1634548872628.png

vkellymsft_1-1634548879677.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

Like this one, it needs to be different. 

TK12345_2-1634557133808.png

 but we are almost there, thanks for the help so far

Hi  @TK12345 ,

 

Yes,using Power query can solve it and will be much easier.

First group rows as below:

vkellymsft_0-1634618555940.png

Then add an index column from 1 and expand the date column;

And you will see:

vkellymsft_1-1634618605004.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

 

Hi there,


Thanks for this one, wil almost give it "accept as solution".  De one in the screenshot is working great, but when i check it with other employee numbers it is exactly the opposite. As you can see in the picture underneeth. When i look into this one it says 1 by the second function, it has to be based on the Month/Year. So we are so close, but maybe this one is possible to solve with a extra filter or in the power query?

TK12345_0-1634556729704.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.