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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX measure required

Good morning Magnificent Humans,

 

I have been trying to crack this nut for the past couple days with no luck with my limited experience.

 

I have 3 tables: 1 Data (multiple columns) and 2 Look up with 1 to 1 relationships to the Data table that only have 2 columns each.

 

All the tables have a unique [EMP ID] column value which their relationship is mappped to.

 

I need to count rows of Table2 [EMP ID] column only if values are NOT found in Table3  [EMP ID]

I'm looking for a total count #

 

I hope this makes sense, thanks in adance.

1 ACCEPTED SOLUTION

Great, since 'ALL POS' has a 1-1 relationship with both tables, we can build a single 'New Column' on this table to acomplish what you need....  

 

Vac wo Plan = IF(RELATED('VAC POS'[EmpID]) <> BLANK(), IF(RELATED('WPA POS'[PosNo]) = BLANK(), "Blank VAC wo Plan"))
 
You can either change the final text to 1, and COUNT the results, or leave it text and 
Count = COUNTA('All POS'[Vac wo Plan]) the new coulmn as a measure to get your result.
 

Capture4.PNG




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

8 REPLIES 8
fhill
Resident Rockstar
Resident Rockstar

Based on your notes, i'm assuming your table structure looks like this with a Data Table, and 2 'Many to 1' Linked Tables.  (Key point here is there's no connection between EmpID on Table1 & Table 3.  Only 2 different connections to the Data Table.)

Capture.PNG

 

Take this in 2 easy steps.  1:  Identify if EmpID is present in Table3, and create a Custom Column as such on Table 1...

      Is In Table 3 = LOOKUPVALUE(Table3[Table 3 Data],Table3[EmpID],Table1[EmpID])

 

2:  Then you can use a simple IF statement in the CountRows calcuation....

     Count Table 2 = IF('Table1'[Is In Table 3] = BLANK(),BLANK(), CALCULATE(COUNTROWS('Data Table')))

 

Sample below.  If this isn't right, or there's more details you haven't shared, please post sample clensed data from your Tables, and screen shot of the Relationship Joins.

 

Forrest

 

Capture2.PNG




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Can you show us a screenshot of the model?
Or the PBIX itself if possible.

Anonymous
Not applicable

Here is the data model however I had changed the POS NO for EMP ID in my example as from experience its easyier to understand.

 

Class Measure.PNG

 

So if i understand from your comments it would be best if we started from the Data Table (ALL Pos) and count only Pos No values found on Lookup Table (VAC) but not found on Lookup Table (WPA). Is that correct, and if so; is it doable?

 

Thanks in advance and I apologize for the wait.

The screen shot helps, but I'm a bit lost again on what you are trying to do.  Now that I can see your data columns, can you ask again...   (If Present <Here>, but NOT <here>, Count <here>?)

FOrrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

certainly Forrest,

 

Pos No (Position Number) is a unique identifier of a box (position) in an organizational chart, the VAC table is the list of those Pos No's that are vacant; and the WPA Table is a list of Pon No's that have staffing plans.

I am trying to get a count of (Total # on a Card visual) positions that are vacant but do not have a staffing plan.

 

Calculate('ALL Pos' [Pos No], only if found on 'VAC' [Pos No] but not found on 'WPA' [Pos No].

 

Class Measure 3.PNG

Great, since 'ALL POS' has a 1-1 relationship with both tables, we can build a single 'New Column' on this table to acomplish what you need....  

 

Vac wo Plan = IF(RELATED('VAC POS'[EmpID]) <> BLANK(), IF(RELATED('WPA POS'[PosNo]) = BLANK(), "Blank VAC wo Plan"))
 
You can either change the final text to 1, and COUNT the results, or leave it text and 
Count = COUNTA('All POS'[Vac wo Plan]) the new coulmn as a measure to get your result.
 

Capture4.PNG




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Much apreciated Forrest, you sir are a god among men.

Now I have to investigate and learn why your solution works!

Have a great weekend.

 

 

Vac wo Plan =               

IF(    --If Statement--

     RELATED(      -- Looks at RELATED Values in Joined Tables--

                      'VAC POS'[EmpID]) <> BLANK()  -- Looking for Non Blank Rows in the EmpID (PosNO) data of the VAC POS Table,                                                                               but because this is Nested inside a REALTED function, it match PosNO to PosNO in both tables.  If there's no matching PosNO value in the REALTED table, a BLANK is returned instead of the RELATED Value.  Therefor <> BLANK() basically looks for ANY RELATED Value in the 2nd table.

        --IF TRUE (finds a non-blank *Related* Value) THEN --                    

                       , IF(    -- Second IF Statement --

                             RELATED(  -- Again, only looking for REALTED values (match PosNO to PosNO) but this time in the WPA POS Table

                                    'WPA POS'[PosNo]) = BLANK()    -- this time Looking for BLANK (Doesn't exist) values.

, "Blank VAC wo Plan"))   -- If True Again we have Non-Blank RELATIONs from the frist table (exists), AND Blank RELATIONs form teh 2nd table (doesn't exist).  Then return what I've typed in the "" marks.

 

** Typcailly IF statements have a 2nd , (comma) for =IF( (Question), Then (Result), Else (other Result)   ).  The 'Else' is always optional though, and not needed here. **




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.