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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Compare strings in previous month

Hello. I need a DAX Measure to count how many staff employees got promoted into a leadership position. This is what my data looks like. So it would need to return 1 because 101 was staff. 102's promotion doesnt count because he was already in a leadership position.

 

IDDateManagerial LevelPromotion
10110/20Staff 
10210/20Manager 
10310/20Staff 
10410/20Director 
10111/20ManagerPromotion
10211/20Executive ManagerPromotion
10311/20Staff 
10411/20Director 

 

Thanks

4 REPLIES 4
Payeras_BI
Solution Sage
Solution Sage

Hello @Anonymous,

 

Try with this measure:

Count of Promotions from Staff =
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            'Table',
            "Previous managerial level",
                VAR __id = 'Table'[ID]
                VAR __date = 'Table'[Date]
                RETURN
                    MAXX (
                        TOPN (
                            1,
                            FILTER (
                                ALL ( 'Table' ),
                                'Table'[ID] = __id
                                    && 'Table'[Date] < __date
                            ),
                            'Table'[Date], DESC
                        ),
                        'Table'[Managerial Level]
                    )
        ),
        [Previous managerial level] = "STAFF"
            && 'Table'[Promotion] = "Promotion"
    )
)

 

Payeras_BI_0-1605885369377.png

Payeras_BI_2-1605885759496.png

Payeras_BI_3-1605885853487.png

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
amitchandak
Super User
Super User

@Anonymous , Try a measure like

calculate( count(Table[Promotion]) , filter(Table, Table[Promotion] = "Promotion" && Table[ Managerial Level] in { "Staff" ,"Manager"}))

 

or

 

calculate( count(Table[Promotion]) , filter(Table, Table[Promotion] = "Promotion" && Table[ Managerial Level] in { "Staff" }))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@MattAllington Hi. I don't have access to the data source. I can't add new columns. I want to try to solve this using DAX to avoid having to request a change in the database.

MattAllington
Community Champion
Community Champion

Power BI is easy when you prep your data. I would add a conditional column using Power Query to indicate if the Mgr level is considered to be a staff promotion. Then you can write a simple DAX formula

CALCULATE(COUNTROWS(Table),table[promotion]="Promotion",table[new column]="from staff")



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.