Countif using DAX in Power Query

jansi79

New Member
Joined
Feb 5, 2016
Messages
18
Hello, does anyone know how I can write the formula:
COUNTIF([Child];[@Parent]) using DAX?
I have a list of 1.000.000 records that I need to identify row by row if the Parent is part of the Child

Regards

Jan Sigve
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
You could create two Queries:

Query 1 on the child Table (cTbl for the example)


Excel 2010
A
1Child
2AAA
3BBB
4BBB
5BBB
6CCC
7CCC
8CCC
9DDD
10EEE
11EEE
12FFF
13FFF
14GGG
15
Sheet3


And group by Child and add a Count Column:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="cTbl"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Child", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Child"}, {{"cCount", each Table.RowCount(_), type number}})
in
    #"Grouped Rows"

Query 2 on the Parent Table or field... (pTbl for this example)


Excel 2010
A
1Parent
2AAA
3BBB
4CCC
5EFR
6TGY
7GGG
8
Sheet4


The Join the Count column From Query 1:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="pTbl"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type",{"Parent"},cTbl,{"Child"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"cCount"}, {"NewColumn.cCount"})
in
    #"Expanded NewColumn"

The resulting Table:


Excel 2010
EF
1ParentNewColumn.cCount
2AAA1
3BBB3
4CCC3
5GGG1
6EFR
7TGY
8
Sheet4
 
Upvote 0
Hello, what I want to achieve is to identify the values in Parent, Grandparent and Great grandparent that is not in the Child column.
Does anyone know how I can do this using Power Query?

Regards
Jan Sigve

ChildParentGrandparentGreat grandparentCount ParentCount GrandparentCount Great Grandparent
131--
261--
3101--
481--
541--
61318-11
7181--
8101--
9---
10181--
11---
1213-1-
13181--
1425--0
1518--1
162222-00
1723-0-
182123-00
19---
20240--

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,194
Messages
6,123,569
Members
449,108
Latest member
rache47

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top