March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hey everyone, I have my table one, who look like this :
Location | X | Y |
Location_1 | A | B |
Location_1 | B | C |
Location_2 | A | C |
Location_4 | C | A |
... | ... | ... |
I've created another table manually to which I'd like to add the count of each note by Location in another column, but I can't manage to code it in DAX to do this, can someone help me?
Expected output :
Location | Rank | Count_X | Count_Y |
Location_1 | A | 56 | 10 |
Location_2 | A | 38 | 16 |
Location_3 | A | 23 | 63 |
Location_4 | A | 12 | 65 |
Location_1 | B | 75 | 26 |
Location_2 | B | 83 | 37 |
Location_3 | B | 94 | 74 |
Location_4 | B | 35 | 73 |
Location_1 | C | 64 | 15 |
Location_2 | C | 194 | 64 |
Location_3 | C | 285 | 25 |
Location_4 | C | 186 | 241 |
(All numbers are here for example)
Thanks all for any help !
Solved! Go to Solution.
Unpivot your "Table one" to bring it into usable format.
Then you can use implicit measures to achieve your result, no need for DAX.
Hi @Ouhla
@lbendlin Thank you very much for your prompt reply, and allow me to add something here.
As @lbendlin mentioned, you need to do unpivot columns for column "X" and column "Y" and then do the calculations.
Here's some dummy data
“Table”
Select two columns in the power query and click unpivot columns.
Create measures.
Count_Y =
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
'Table'[Location] = MAX('Table'[Location])
&&
'Table'[Attribute] = "Y"
&&
'Table'[Rank] = MAX('Table'[Rank])
)
)
Count_X =
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
'Table'[Location] = MAX('Table'[Location])
&&
'Table'[Attribute] = "X"
&&
'Table'[Rank] = MAX('Table'[Rank])
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Ouhla
@lbendlin Thank you very much for your prompt reply, and allow me to add something here.
As @lbendlin mentioned, you need to do unpivot columns for column "X" and column "Y" and then do the calculations.
Here's some dummy data
“Table”
Select two columns in the power query and click unpivot columns.
Create measures.
Count_Y =
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
'Table'[Location] = MAX('Table'[Location])
&&
'Table'[Attribute] = "Y"
&&
'Table'[Rank] = MAX('Table'[Rank])
)
)
Count_X =
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
'Table'[Location] = MAX('Table'[Location])
&&
'Table'[Attribute] = "X"
&&
'Table'[Rank] = MAX('Table'[Rank])
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Unpivot your "Table one" to bring it into usable format.
Then you can use implicit measures to achieve your result, no need for DAX.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
15 | |
12 | |
9 | |
8 |
User | Count |
---|---|
41 | |
32 | |
29 | |
12 | |
12 |