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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Sonu88
New Member

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
v-yiruan-msft
Community Support
Community Support

@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

Community Support Team _ Rena
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

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
v-yiruan-msft
Community Support
Community Support

@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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.