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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Group Measure and Count the number of members in each group.

Hi community,

 

I am still learning and i wanted your help. 

 

Sample of data: (Weekly scale)

 

YearQuarterWeekNumberModelSiteMetricActualValue
201811A10Sales10001010
201812A10Sales10501020
201813A10Sales10301000
201814A10Sales11001040
201815A10Sales20001500
201816A10Sales25002000

 

The above data has the below number of categories for each column.

Years: 1

Quarters: 4

Weeks:52

Models: 2

Sites: 255

Metrics: 4

 

I caclulated the MAPE using a measure calculation as shown below. 

MAPE_mean_wk = AVERAGEX(Weekly_Actual,(ABS([WeeklyActual]-[WeeklyValue]))/ ABS([WeeklyActual]) ) *100

 

OBJECTIVE: I want to bucket the MAPE measure into groups of 0-5%, 5-10% 10-15%, etc. , and calculate the number of sites in each group while i can also filter by Models, Metrics, Quarters. 

 

Desired Outcome:

 

 Sites Count
0-5%60
5-10%80
10-15%70
15-20%40
>20%5
Total:255

 

If no filter is selected, i want the average across all data. For example, if i filter to only quarter 1 i want average MAPE for each strore over quarter 1.

 

What i have tried so far, i created the below column,

 

Bucket Range2 = SWITCH( TRUE(),
Weekly_Actual[MAPE_mean_wk]<=5,"0-5%",
Weekly_Actual[MAPE_mean_wk]<=10,"5-10%",
Weekly_Actual[MAPE_mean_wk]<=15,"10-15%",
Weekly_Actual[MAPE_mean_wk]<=20,"15-20%",
Weekly_Actual[MAPE_mean_wk]<=25,"20-25%",
Weekly_Actual[MAPE_mean_wk]<=30,"25-30%",
Weekly_Actual[MAPE_mean_wk]<=35,"30-35%",
Weekly_Actual[MAPE_mean_wk]<=40,"35-40%",
Weekly_Actual[MAPE_mean_wk]<=50,"40-50%",
Weekly_Actual[MAPE_mean_wk]>50,"50%+")

 

and then i added it to a table with a distinctCount of Sites but the outcome is not as expected.

Screenshot 2019-07-10 at 10.52.57.png

I think the problem is that it does not aggregate across the other columns but i couldn't find a way so far. 

 

Any help will be highly appreciated. 

 

 

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

Current power bi not allow to create dynamic calculated column/table based on filter/slicer. For this scenario, you can write measure to achieve dynamic changes. (notice: if you use this measure in calculated column, its calculated result will been fixed not dynamic changes)

In my opinion, I'd like to suggest you create a table with all type of ranges, then write a measure formula to calculate with original table based on current category label.

If you confused on coding formula, please share pbix file with detail sample data for test.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

Current power bi not allow to create dynamic calculated column/table based on filter/slicer. For this scenario, you can write measure to achieve dynamic changes. (notice: if you use this measure in calculated column, its calculated result will been fixed not dynamic changes)

In my opinion, I'd like to suggest you create a table with all type of ranges, then write a measure formula to calculate with original table based on current category label.

If you confused on coding formula, please share pbix file with detail sample data for test.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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