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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How would I create this table virtually?

rather than via maniupulation in power query would it be possible to take the following data:

employee id gender score
1 m 3
2 m 7
3 f 5
4 f 8
5 f 4
6 m 6
7 m 9
8 f 2
9 m 1
10 f 4

 

and turn it into this virtually? (count of those with score >5 (true) and =<5 (false))

gender > 5 count
m TRUE 3
m FALSE 2
f TRUE 1
f FALSE 4

 

ideally i would like adjust the score threshold via a slicer too, presumably this would done using SELECTEDVALUE(slicer) and SWITCH within the DAX for the above?

 

any help would be greatly appreciated.

6 REPLIES 6
jgeddes
Super User
Super User

You can try something like this...

scoreSummarytable = 
var _threshold =
5
var _vTable =
UNION(
    ROW("gender", "m", "greaterThanThreshold", TRUE(), "score", CALCULATE(COUNT(scoreTable[employee id]), scoreTable[score] > _threshold && scoreTable[gender] = "m")),
    ROW("gender", "m", "greaterThanThreshold", FALSE(), "score", CALCULATE(COUNT(scoreTable[employee id]), scoreTable[score] <= _threshold && scoreTable[gender] = "m")),
    ROW("gender", "f", "greaterThanThreshold", TRUE(), "score", CALCULATE(COUNT(scoreTable[employee id]), scoreTable[score] > _threshold && scoreTable[gender] = "f")),
    ROW("gender", "f", "greaterThanThreshold", FALSE(), "score", CALCULATE(COUNT(scoreTable[employee id]), scoreTable[score] <= _threshold && scoreTable[gender] = "f"))
)
Return
_vTable




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Anonymous
Not applicable

Oh I'm sorry! When you say virtually you say that you want a dax calculated table? I thought you was saying that does not want to create any table

Anonymous
Not applicable

Hi Vitor, Yes, created via DAX, I presume it might involve CALCULATETABLE, ADDCOLUMNS etc but I am struggling with how to create this.

Anonymous
Not applicable

Try this out please,

First, if possible, you create this column on the main table: SCORE <5 = if('table'[score] < 5, TRUE, FALSE)

then you try:


#edit

 

SUMMARIZE(
'table',
'table'[gender],
'table'[SCORE <5],
"Count", countrows('table')
)

Anonymous
Not applicable

Hello @Anonymous,

 

If i had this same problem to resolve, I would make like this:

 

Put the "Gender" column on a table visual, then create a measure: [[  Score <5 = if('score'[score] < 5, TRUE, FALSE)  ]] and put in the same table.

 

Then put the "Employee id" go on the field and choose "Count".

 

😄

Anonymous
Not applicable

Hi Vitor,

 

For the avoidance of doubt, I'd like to create this virtually as I intend on doing doing further manipulation after this step. 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.