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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
TSGD2123
Helper I
Helper I

Measures to aggregate by month & range values

Hi all,

My data table is something like:

TSGD2123_0-1666780095004.png

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:

TSGD2123_1-1666780280656.png

 

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

TSGD2123_2-1666780353440.png

 

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

Thanks a lot in advance!

 

 

 

 

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

Hi @TSGD2123 ,

 

Like this?

vmengzhumsft_0-1667465142718.png

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

 

View solution in original post

4 REPLIES 4
v-mengzhu-msft
Community Support
Community Support

Hi @TSGD2123 ,

 

Like this?

vmengzhumsft_0-1667465142718.png

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

 

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

daXtreme
Solution Sage
Solution Sage

Yes. It's possible.

Great! Could you go into further detail?

 

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 MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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