Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi all!
Can you help me to build a DAX measure, please?
So I have two tables.
The first one looks like this, it shows the participating organizations (columns from partner1 to partner5) by location and sales for each row.
The second table is like this, it shows the type of each Organization.
Solved! Go to Solution.
H @yoleksandr and @DimaMD
I don't have access to my laptop right now but you may try
=
COUNTROWS (
INTERSECT (
VALUES ( table2[Organization] ),
DISTINCT (
UNION (
VALUES ( table1[partner1] ),
VALUES ( table1[partner2] ),
VALUES ( table1[partner3] ),
VALUES ( table1[partner4] ),
VALUES ( table1[partner5] )
)
)
)
)
@tamerj1 Hi, so this measure gave the correct result, @yoleksandr use the measure provided @tamerj1
H @yoleksandr and @DimaMD
I don't have access to my laptop right now but you may try
=
COUNTROWS (
INTERSECT (
VALUES ( table2[Organization] ),
DISTINCT (
UNION (
VALUES ( table1[partner1] ),
VALUES ( table1[partner2] ),
VALUES ( table1[partner3] ),
VALUES ( table1[partner4] ),
VALUES ( table1[partner5] )
)
)
)
)
thanks a lot! works great!
@tamerj1 Hi, so this measure gave the correct result, @yoleksandr use the measure provided @tamerj1
It gives a table of this kind
Now the question is whether it is possible to create a measure out of the above formula, this measure should calculate the disctinct count of organization by type. But I don't need to create a separate table, only a measure (the full dataset is 200K entries, so additional table would be redundant and slow the performance).
@yoleksandr yes try it measure, only I see that the total counts incorrectly
OrganizationsCount =
VAR VirtualTable =
NATURALINNERJOIN(
TREATAS(
DISTINCT(FILTER(
UNION(
SELECTCOLUMNS(sales, "partner", sales[partner1], "location", sales[location]),
SELECTCOLUMNS(sales, "partner", sales[partner2], "location", sales[location]),
SELECTCOLUMNS(sales, "partner", sales[partner3], "location", sales[location]),
SELECTCOLUMNS(sales, "partner", sales[partner4], "location", sales[location]),
SELECTCOLUMNS(sales, "partner", sales[partner5], "location", sales[location])),
[partner] <> "")), dim_types[Organization], sales[location]),dim_types)
VAR FilteredTable =
CALCULATE( COUNTROWS(VirtualTable), FILTER(VirtualTable, [Organization] = SELECTEDVALUE(dim_types[Organization])))
RETURN
FilteredTable
hi @DimaMD ,
thanks a lot for this, I see we're really close to the correct solution, but not there yet.
The issue is that I need to have DISTINCTCOUNT of [partner] column from the virtual table, but the below variant of the FilteredTable is not working:
@tamerj1 Hello , maybe you have an idea how to calculate it?
@yoleksandr hi, look at the attached file and answer if this is the desired result
hi @DimaMD ,
Thanks a lot for this, but it's not exactly what I need.
Sorry if it wasn't clear initially, I added one line to the fist message now.
So I need to keep the structure of the table, it should not be changed. You unpivoted the columns with partners, but with this the data in "sales" column is now repeated many times, so it gives the wrong result. Hope what I mean is clear.
in any case, Slava Ukraini!
i think you can add a concatinating column where you concat values and then , see if it contains in the column teh value
hello first pivot your first table for all 5 partners this way , you will have 2 columns , partners and organization column ,
next create 2 dim tabes one with distinct values of organizatio nand one with distinct values of partners
now link the tbales via one to many relationship
Thanks, but I need to keep the same structure of the table, no unpivots (sales column will give a wrong result in this case).
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
17 | |
10 | |
10 | |
8 | |
6 |
User | Count |
---|---|
18 | |
16 | |
15 | |
12 | |
10 |