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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Sonu88
Frequent Visitor

Excluding Departments Not Present in Last Month's Data in Power BI

Hi Expert,

 

 I'm interested in comparing the resource count between any two given months say April and May for those departments that were existed in the previous month as well. For instance, in the given table, Department 2 did not exist in the previous month, so it should be excluded from the calculation of resource count.

I need assistance to dynamically remove/filter out those departments which were not exist in previous month from my table either by power query or via DAX.

Input Data

 

ResourceDeaprtmentAssignment Date 
Resource 1Deaprtment 14/1/2024
Resource 2Deaprtment 14/1/2024
Resource 3Deaprtment 15/1/2024
Resource 4Deaprtment 25/1/2024
Resource 5Deaprtment 25/1/2024
   

Required Table

ResourceDeaprtmentAssignment Date
Resource 1Deaprtment 14/1/2024
Resource 2Deaprtment 14/1/2024
Resource 3Deaprtment 15/1/2024
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@lbendlin @Ashish_Mathur  Thanks for your contribution on this thread.

Hi @Sonu88 ,

You can follow the steps below to get it, please find the details in the attachment.

1. Create a measure as below

Flag = 
VAR _department =
    SELECTEDVALUE ( 'Table'[Deaprtment] )
VAR _departs =
    CALCULATETABLE (
        VALUES ( 'Table'[Deaprtment] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            MONTH ( 'Table'[Assignment Date] )
                = MONTH ( TODAY () ) - 1
        )
    )
RETURN
    IF ( _department IN _departs, 1, 0 )

2. Create a table visual and apply a visual-level filter on it with the condition (Flag is 1)

vyiruanmsft_0-1715679182086.png

Best Regards

View solution in original post

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1715737325386.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

@lbendlin @Ashish_Mathur  Thanks for your contribution on this thread.

Hi @Sonu88 ,

You can follow the steps below to get it, please find the details in the attachment.

1. Create a measure as below

Flag = 
VAR _department =
    SELECTEDVALUE ( 'Table'[Deaprtment] )
VAR _departs =
    CALCULATETABLE (
        VALUES ( 'Table'[Deaprtment] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            MONTH ( 'Table'[Assignment Date] )
                = MONTH ( TODAY () ) - 1
        )
    )
RETURN
    IF ( _department IN _departs, 1, 0 )

2. Create a table visual and apply a visual-level filter on it with the condition (Flag is 1)

vyiruanmsft_0-1715679182086.png

Best Regards

Ashish_Mathur
Super User
Super User

Hi,

Quite confused about what you want.  In the text, you mention that you want a count but yo have shown the expected result as a Table.  Show the expected result very clearly.  Share data in a format that can be pasted in an Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello Ashish 

 

Many apologizes,  please consider the 'Required Table' table as a desired result. Once i am able to generate the final table which excludes those departments, then I can create required measures. I hope it clean now.

If you want to compare 2 months, then atleast share data for 2 months in the sample dataset.  Your sample data has just 1 month.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish 

 

The input table has already May month data under Assignment Date column.

 

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1715737325386.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

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