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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Surya9
Resolver III
Resolver III

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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