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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Zakhamido
Frequent Visitor

Matching Values from 2 tables

I have a problem and I am seeking for help, I have an issue with a DAX formula.

First of all let me explain my requirment, I have 2 tables one in direct query and the other in import mode 

The first table is called TibcoIncident which is for outage affected substations data and the other table is called Medical Case which will have all the customers that is registered that Have a critical medical devices, now I want for every record to come in the TibcoIncident Table to check if this substation is available in the table 'Medical Case' and then count the number of affected customers from that table and then display the number of the measure in card. 

 

Now my issue is I am unable to find a way to do it, my current formula (Below) will do it perfectly when I select a record from the table but will not count automatically for records, I think because I am using SelectedValue function so is there any way to do my requirment ?

 

Just to note that my common column in the 2 tables is substation number

 

Zakhamido_0-1706079520394.png

 

 

 

1 ACCEPTED SOLUTION

@Zakhamido 

Please try this meaure:

MatchedAccounts =
SUMX (
    ADDCOLUMNS (
        TIBCOINCIDENT_UPDATED,
        "__DCount",
            VAR CurrentSubName = TIBCOINCIDENT_UPDATED[SUB_NAME]
            VAR CurrentStatus = TIBCOINCIDENT_UPDATED[STATUS]
            VAR CurrentOutageTime = TIBCOINCIDENT_UPDATED[Outage_Time_UAE]
            VAR CurrentTime =
                NOW ()
            RETURN
                IF (
                    CurrentStatus = "Un-Planned Pending"
                        && CurrentOutageTime > CurrentTime - 24,
                    CALCULATE (
                        DISTINCTCOUNT ( 'Medical Case'[Per Src Id] ),
                        'Medical Case'[Substation] = CurrentSubName
                    )
                ) + 0
    ),
    [__DCount]
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

4 REPLIES 4
Zakhamido
Frequent Visitor

Thanks a lot 

Fowmy
Super User
Super User

@Zakhamido 

Could you paste the DAX measure in the reply rather than the image so I can modify it for you?


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

MatchedAccounts =
VAR CurrentSubName = SELECTEDVALUE(TIBCOINCIDENT_UPDATED[SUB_NAME])
VAR CurrentStatus = SELECTEDVALUE(TIBCOINCIDENT_UPDATED[STATUS])
VAR CurrentOutageTime = SELECTEDVALUE(TIBCOINCIDENT_UPDATED[Outage_Time_UAE])
VAR CurrentTime = NOW()

RETURN
IF (
    CurrentStatus = "Un-Planned Pending" && CurrentOutageTime > CurrentTime - 24,
    COALESCE(
        CALCULATE (
            COUNTROWS(
                DISTINCT(
                    'Medical Case'[Per Src Id]
                )
            ),
            FILTER (
                'Medical Case',
                'Medical Case'[Substation] = CurrentSubName
            )
        ),
        0
    ),
    0
)

@Zakhamido 

Please try this meaure:

MatchedAccounts =
SUMX (
    ADDCOLUMNS (
        TIBCOINCIDENT_UPDATED,
        "__DCount",
            VAR CurrentSubName = TIBCOINCIDENT_UPDATED[SUB_NAME]
            VAR CurrentStatus = TIBCOINCIDENT_UPDATED[STATUS]
            VAR CurrentOutageTime = TIBCOINCIDENT_UPDATED[Outage_Time_UAE]
            VAR CurrentTime =
                NOW ()
            RETURN
                IF (
                    CurrentStatus = "Un-Planned Pending"
                        && CurrentOutageTime > CurrentTime - 24,
                    CALCULATE (
                        DISTINCTCOUNT ( 'Medical Case'[Per Src Id] ),
                        'Medical Case'[Substation] = CurrentSubName
                    )
                ) + 0
    ),
    [__DCount]
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.