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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
mmyers2
Advocate I
Advocate I

Count by Measure Group

I have a simple table with customer/SKU level sales data by week.

 

I have two measures:

 

Cust Avg Qty/Wkly = AVERAGEX(SUMMARIZE('Cust Usage','CUST Usage'[CUST_ID],
'CUST Usage'[PRODUCT_NUMBER], 'CUST Usage'[WEEK_OF_YEAR]),
CALCULATE(SUM('Cust Usage'[CUST_QTY_SHIPPED])))

 

CV Cust 2 = 
SWITCH(TRUE(),STDEVX.S(SUMMARIZE('Cust Usage','CUST Usage'[CUST_ID],'CUST Usage'[PRODUCT_NUMBER],
'CUST Usage' [WEEK_OF_YEAR]),CALCULATE(SUM('Cust Usage'[CUST_QTY_SHIPPED])))/
'Cust Usage'[Cust Avg Qty/Wkly]<0.25,"1. Runner",
STDEVX.S(SUMMARIZE('Cust Usage','CUST Usage'[CUST_ID],'CUST Usage'[PRODUCT_NUMBER]
, 'CUST Usage'[WEEK_OF_YEAR]),CALCULATE(SUM('Cust Usage'[CUST_QTY_SHIPPED])))/
'Cust Usage'[Cust Avg Qty/Wkly]<0.5,"2. Repeater",
"3. Stranger") 
 

 

What I am having an issue with is counting the number of distinct products based on CV Cust 2. It works fine as long as I don't count products, but as soon as I try to count product, it shows all products as "3. Stranger", and does not show anything for the other 2 groups.

 

CV Cust 2 needs to stay a measure, as it needs to recalculate as more/less customers are selected in a slicer.

 

I have tried many different things, and have not gotten the results I am looking for.

 

I would also like to be able to put the data in a chart that shows the number of SKUs by CV Cust 2, but cannot use a measure as an axis. 

 

Any ideas/help would be greatly appreciated.

8 REPLIES 8
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @mmyers2,

 

How did you count a measure? Maybe you need a Summarize to count a measure. 

How did you create a visual? Maybe the formula can be simplified like this.

Cust Avg Qty/Wkly =
AVERAGEX ( 'Cust Usage', SUM ( 'Cust Usage'[CUST_QTY_SHIPPED] ) )

And the report visual coule be:

'CUST Usage'[CUST_ID],   'CUST Usage'[PRODUCT_NUMBER],  'CUST Usage'[WEEK_OF_YEAR]),  [Cust Avg Qty/Wkly]

 

About the visual you wanted, maybe you can create a table "MeasureValues" with the possible values of the measure. Then create a new measure like this:

New Measure =
VAR mvalue =
    MAX ( MeasureValues[column] )
RETURN
    SUMX ( 'table', IF ( 'table'[Old Measure] = mvalue, 1, 0 ) )

Please give it a try.

 

Best Regards!

Dale

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I tried the simplified weekly average, and it did not summerize correctly. I need the measure to summarize based on customer, product, and week, regardless of what I use it.

 

When I use the formula for a visual, here is what I get, which is not correct. This is what I get no matter what formula I use. 

 

RRS.jpg

 

Surely there has to be a way to count records based on dynamic categories. 

 

Here is an example of how it should look. I used static data in a table to create this, but I need it to be dynamic.

 

RRS Example.jpg 

Here is a link to a sample of the model.

 

I really need to get this working.

 

Dropbox Link

Anyone?

Hi @mmyers2,

 

You need add [CV Cust 2] as a calculated column. Then your measure [# of SKUs2] will work. You check it out in this file: https://1drv.ms/u/s!ArTqPk2pu-BkgUKnj3Uf866VcyMS.

Count by Measure Group.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

 

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft

 

Thank you for the reply, but a calculated column does not work as it is not dynamic.

 

CV Cust 2 needs to stay a measure, as it needs to recalculate as more/less customers are selected in a slicer.

Hi @mmyers2,

 

Measures need context while your visual doesn't have one. That's why the result is always "3. Stranger". You still can select the values of many columns in a slicer when you use a calculated column. What kind of dynamic do you expect? 

 

Best Regards!

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft

 

The only way I can think of to explain it, is with an example.

 

Let's say item A is a "1.Runner" when looking at all customers.

 

When I select customers 1, 2, and 3, item A is a "2.Repeater" because the calculation is only looking at the numbers for those customers.

 

Then, if I select only customer 1, item A is a "3.Stranger" because the calculation is only looking at the numbers for customer 1.

 

We have also been trying to do this with an ABC calculation based on number of sales, but get the same issue.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors