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
Surya9
Helper V
Helper V

filter data in measure based on multiple columns and measure

I have 2 tables Employee and Leaves Having relationship Many to many from Employee to Leave based in Empid

Employee
Empid
Status
Enddate
Flg

 

Leave 
Empid 
StartDate
Enddate

I had created the measure1 in leave to check whether Empid met the condition or not 
if condition is met then 1 else 0
now i have to create the measure for Employee 
= CALCUALTE ( Distinctcount(Employee[Empid]), 
                          Filter (Employee, 

                                        AND ( AND (Status IN {"IN","Working"},
                                                    ISBLANK (Enddate)),

                                                  OR ( Flg = 0 ,
                                                          Employee[Empid] IN Values( All the Empid from Leave where Measure1 Value is 1))))

Please help me with this or any best approach to achive this

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Surya9 ,

I created a sample pbix file(see attachment), please check whether that is what you want. You can update your measure as below:

Measure2 = 
VAR _tab =
    CALCULATETABLE ( VALUES ( 'Leave'[Empid] ), FILTER ( 'Leave', [Measure] = 1 ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Employee[Empid] ),
        FILTER (
            Employee,
            AND (
                AND (
                    'Employee'[Status] IN { "IN", "Working" },
                    ISBLANK ( 'Employee'[Enddate] )
                ),
                OR ( 'Employee'[Flg] = 0, Employee[Empid] IN _tab )
            )
        )
    )

yingyinr_0-1641280034263.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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Surya9 ,

I created a sample pbix file(see attachment), please check whether that is what you want. You can update your measure as below:

Measure2 = 
VAR _tab =
    CALCULATETABLE ( VALUES ( 'Leave'[Empid] ), FILTER ( 'Leave', [Measure] = 1 ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Employee[Empid] ),
        FILTER (
            Employee,
            AND (
                AND (
                    'Employee'[Status] IN { "IN", "Working" },
                    ISBLANK ( 'Employee'[Enddate] )
                ),
                OR ( 'Employee'[Flg] = 0, Employee[Empid] IN _tab )
            )
        )
    )

yingyinr_0-1641280034263.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.
aj1973
Community Champion
Community Champion

Hi @Surya9 

You request is not quite clear but in my understanding you should use IF statement then DISTINCTCOUNT to get it work.

May be share a Sample Pbix would be better for the community to help you.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

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.