cancel
Showing results 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.

Resolver I

## Total records that are above on or below from a vertical table

Is it possible to count the total rows that are above 0 in the OutPut table or below 0 as percentage of the overall total records.

SourceTable

 Name Result Collection Name 1 87 2 Name 1 92 1 Name 2 107 2 Name 2 110 1 Name 3 106 1 Name 3 107 2 Name 4 85 2 Name 4 94 1 Name 5 99 2 Name 5 107 1 Name 6 105 1 Name 6 107 2 Name 7 96 2 Name 7 99 1 Name 8 108 2 Name 8 111 1 Name 9 111 1 Name 9 114 2

DAX to creat the OutPut

``````Current =
Var MostRecentCollection = Max('SourceTable'[Collection]
RETURN
CALCULATE(AVERAGE('SourceTable'[Result]),
FILTER(
ALL('SourceTable'[Collection]),
'SourceTable'[Collection] = MostRecentCollection
)
)``````

``````Previouse =
Var MostRecentCollection = Max('SourceTable'[Collection]-1
RETURN
CALCULATE(AVERAGE('SourceTable'[Result]),
FILTER(
ALL('SourceTable'[Collection]),
'SourceTable'[Collection] = MostRecentCollection
)
)``````

OutPut

 Name Current Previouse Difference Name 1 92 87 5 Name 2 110 107 3 Name 3 106 107 -1 Name 4 94 85 9 Name 5 107 99 8 Name 6 105 107 -2 Name 7 99 96 3 Name 8 111 108 3 Name 9 111 114 -3

This is the bit I am getting stuck on.

% of rows that are above 0  (6/9=67%)
% of rows that are below 0  (3/9=33%)

1 ACCEPTED SOLUTION
Community Support

Hi @CEllis

You can try these measures

``````% above 0 =
VAR _table = SUMMARIZE('SourceTable','SourceTable'[Name],"Diff",[Difference])
VAR _allRows = COUNTROWS(_table)
VAR _aboveRows = COUNTROWS(FILTER(_table,[Diff]>0))
RETURN
DIVIDE(_aboveRows,_allRows)``````
``````% below 0 =
VAR _table = SUMMARIZE('SourceTable','SourceTable'[Name],"Diff",[Difference])
VAR _allRows = COUNTROWS(_table)
VAR _belowRows = COUNTROWS(FILTER(_table,[Diff]<0))
RETURN
DIVIDE(_belowRows,_allRows)``````

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Community Support

Hi @CEllis

You can try these measures

``````% above 0 =
VAR _table = SUMMARIZE('SourceTable','SourceTable'[Name],"Diff",[Difference])
VAR _allRows = COUNTROWS(_table)
VAR _aboveRows = COUNTROWS(FILTER(_table,[Diff]>0))
RETURN
DIVIDE(_aboveRows,_allRows)``````
``````% below 0 =
VAR _table = SUMMARIZE('SourceTable','SourceTable'[Name],"Diff",[Difference])
VAR _allRows = COUNTROWS(_table)
VAR _belowRows = COUNTROWS(FILTER(_table,[Diff]<0))
RETURN
DIVIDE(_belowRows,_allRows)``````

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Announcements

#### 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

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors