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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
dparaman
New Member

Need help with DAX

Hi Everyone, 

 

I am new to power bi and I am struggling with implementation of a card visual. 

 

The data model structure:
I have all_orgs table that has information for all the orgs present. Let's say org_id and org_member(yes or no field). Let's say I have 5k+ records in this table. 

 

I have another table participants which has 375 records only. it contains only [org_id]. Note that not all 375 orgs is present in the all_orgs table. Only 317 of them is present. 

 

I have an active one to one relationship between all_orgs table and the partcipants table with filter direction set to both. 

 

The objective:
I want to show a card visual which shows the count. ie out of 375 participants how many are present in all_orgs table. This I am able to achieve using the following DAX. There are 300 records present in all orgs table. 

CountPresentOrgs =
CALCULATE(
    COUNTROWS('participants'),
    FILTER(
        'participants',
        NOT(
            ISBLANK(
                LOOKUPVALUE(
                    all_orgs[ORG_ID],
                    all_orgs[ORG_ID], 'participants'[ORG ID]
                )
            )
        )
    )
)

however, when I apply the filter is_member on the all_orgs table:
1. the number of records in all_orgs table get reduced to 1k records. 
2. I know that only 200+ participants is present in this filtered table. 
3. the dax should show this 200 count but instead shows the original 300. 
4. Is there a way to get the present count based on the filtered all_orgs table. ie, out of the constant 375, I should get present and not present on the all_orgs_table which might be filtered. 

Any help is appreciated. Thanks!
2 REPLIES 2
v-xingshen-msft
Community Support
Community Support

Hi All,
Firstly sergej_og thank you for your solution!
And @dparaman ,I tried to replicate your data for testing, when using is_member for testing, it is possible to filter according to the filter, it is possible that my data is too simple to replicate your specific problem, we also tried other DAX to realize your needs, you can try to see if it can accomplish your needs!

CountPresentOrgsFiltered = 
CALCULATE(
    COUNTROWS('participants'),
    FILTER(
        'participants',
        NOT(
            ISBLANK(
                RELATED('all_orgs'[ORG_ID])
            )
        )
    )
)
CountPresentOrgsFiltered2 = 
CALCULATE(
    COUNTROWS('participants'),
    TREATAS(
        VALUES(all_orgs[ORG_ID]),
        'participants'[ORG_ID]
    )
)

vxingshenmsft_0-1729757611234.png

I hope my thoughts are helpful, and I would be honored if my approach solves your problem!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

sergej_og
Super User
Super User

Hey @dparaman ,
can you pls provide a screenshot of your model...for better undestanding how fields are connected.
Pls mask sensitive data before sharing.

Thx.

Regards

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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