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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Get Count of Rows for Table Visual Filtered by Measures

I am having issues getting a row count of results based on a measure being filtered by another measure. 

 

I'm calculating an average in a client hierarchy where the most aggregated element will be the store, then chain, and finally channel. So I want to compare the average of the store against the average of the chain to which the store belongs to.  

I'm using this measure that works fine:

210. Facing Avg Store = 
VAR V1 = [201. Facing Avg]
VAR V2 = CALCULATE([201. Facing Avg], ALL(DIM_CLIENT_VW[DESC_CHAIN]), ALL(DIM_CLIENT_VW[DESC_STORE]))
VAR V3 = CALCULATE([201. Facing Avg], ALL(DIM_CLIENT_VW[DESC_STORE])) 
RETURN
IF(HASONEFILTER(DIM_CLIENT_VW[DESC_STORE]),V3,
IF(HASONEFILTER(DIM_CLIENT_VW[DESC_CHAIN]),V2, V1))

Then, I need to count the Stores that are above avg and the stores below avg. To identify them, I'm subtracting the Average minus the Store Avg and creating a flag, depending on if the result is above or below zero like this:
 
210. Benchmark above/below store =
VAR V1 = [201. Facing Avg] - [210. Facing Avg Store]
RETURN
IF(V1 > 0, 1, IF(V1 < 0, -1, BLANK()))
 
The result is ok, I'm able to identify which stores are above and which are below.
The issue is when I try to count the flag and show it on a Card object or use it for another calculation, and I think is because of the aggregation on the original measure [210. Facing Avg Store], If I don't have stores in the axis, the total is blank because any of the conditions are fulfilled.
Is there a way I can get the result I'm looking for? I've tried using a table and filter the table by the flag, and the number I obtain is ok, but I can't use the result in any calculations and I need it to known the % of stores below avg and the % above avg.
 
Hope you can help me,
 
Mijalis
 
1 REPLY 1
V-pazhen-msft
Community Support
Community Support

@Anonymous 

It is difficult to image your model without any data. Please provide some sample.

 

Read this post to describe your sample:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Paul

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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