cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper I

## Measures to aggregate by month & range values

Hi all,

My data table is something like:

Im asked to get a table/histogram with a row/bar per month and the number of IDs per range of summatory of hours/month:

Here is an intermediate table to help you guys understand the requirement:

Is it possible to get it with just with measures/DAX and not having to create the intermediate tale in the data model??

1 ACCEPTED SOLUTION
Community Support

Hi @TSGD2123 ,

Like this?

I created four measures to achieve this goal, as the following show:

``judgement = IF([sum hours]<10,0,IF([sum hours]>=10&&[sum hours]<20,1,IF([sum hours]>=20&&[sum hours]<30,2)))``
``sum hours<10 = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),[judgement]=0&&'Table'[Month]=SELECTEDVALUE('Table'[Month])))``
``````10-sumhours-20 = var _t=SUMMARIZE('Table','Table'[Month],'Table'[ID])
return COUNTROWS(FILTER(_t,[judgement]=1))``````
``````sum hours>20 = var _t=SUMMARIZE('Table','Table'[Month],'Table'[ID])
return COUNTROWS(FILTER(_t,[judgement]=2))``````

The related pbix file I also attached, you can refer for better understanding.

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

4 REPLIES 4
Community Support

Hi @TSGD2123 ,

Like this?

I created four measures to achieve this goal, as the following show:

``judgement = IF([sum hours]<10,0,IF([sum hours]>=10&&[sum hours]<20,1,IF([sum hours]>=20&&[sum hours]<30,2)))``
``sum hours<10 = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),[judgement]=0&&'Table'[Month]=SELECTEDVALUE('Table'[Month])))``
``````10-sumhours-20 = var _t=SUMMARIZE('Table','Table'[Month],'Table'[ID])
return COUNTROWS(FILTER(_t,[judgement]=1))``````
``````sum hours>20 = var _t=SUMMARIZE('Table','Table'[Month],'Table'[ID])
return COUNTROWS(FILTER(_t,[judgement]=2))``````

The related pbix file I also attached, you can refer for better understanding.

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helper I

Yes, great! thanks a lot @v-mengzhu-msft

Solution Sage

Yes. It's possible.

Helper I

Great! Could you go into further detail?

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors