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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Create a measure to sum a calculated column for a slicer

Hey all.  I have a few questions.  The first is: Is it good practice to create a measure on calculated columns when row by row aggregations are necessary?

My example is I have two dates I need to see the difference between.  I need them broken up by hour groups, so less the 2 hours, 2-4 hours, 6-8, and greater than 8.

Exmpale DAX for calculated column in Table2:

 

6To8Hours = IF(DATEDIFF(RELATED(Table1[FromDate]),Table2[ToDate],HOUR) > 6 && DATEDIFF(RELATED(Table1[FromDate]),Table2[ToDate]],HOUR) <= 8, 1, 0)

 

I then create a measure in Table2:

 

 

SUM POS 6 to 8 = CALCULATE(SUM(Table2[6To8Hours]), Table2[6To8Hours] = 1)

 

I tried putting the whole thing in a measure to avoid the calc column but it couldn't find the related table - not sure of the reason for this.

 

My last question is that my end game is to create a slicer to use in a visual using these measures to change what hour group is being displayed.  I am using the instructions found HERE which doesn't seem to get me the whole way as the slicer shows no data in the graph unless I select multiple slicer options - which it then shows the same static numbers no matter what I choose.

 

HourGroupSlicer.jpg

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

Any solution worked out for you?

Do the above replies help? if you need more help make me @

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@Anonymous , you should be able to use related in a measure on the M side.  In case you need bucket on meausre you need to try segmentation - refer: https://www.youtube.com/watch?v=CuczXPj0N-k

 

or

https://www.daxpatterns.com/dynamic-segmentation/

https://radacad.com/grouping-and-binning-step-towards-better-data-visualization

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.