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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PbiCeo
Helper II
Helper II

Calculating average value for a day of a month comparing to other value

Hello everyone,

 

I want to calcutalte average value for a day of a month comparing to other value with Measure:

 

 

Measure1 =
VAR tm = CALCULATE(SUM('table'[data1]), FILTER(ALL('calendar'), 'calendar'[date] <= 'calendar'[date]))
return
DIVIDE('tm', 'table'[NumberofDays], 0)

 

Measure2 =
VAR tm = CALCULATE(SUM('table'[data2]), FILTER(ALL('calendar'), 'calendar'[date] <= 'calendar'[date]))
return
DIVIDE('tm', 'table'[NumberofDays], 0)


MeasureResult = DIVIDE('table'[Mesaure1], 'table'[Measure2], 0)

 

But MeasureResult returns the all same value on Table visual.

How to get value row by row?
Thanks in advance,

Vladi

5 REPLIES 5
amitchandak
Super User
Super User

@PbiCeo , your NumberofDays  measure should be like

 

NumberofDays =CALCULATE(distinctcount('table'[Date]), FILTER(ALL('calendar'), 'calendar'[date] <= 'calendar'[date]))
or
NumberofDays =CALCULATE(distinctcount('calendar'[date]), FILTER(ALL('calendar'), 'calendar'[date] <= 'calendar'[date]))

 

You can this measure like

MeasureResult =

CALCULATE(DIVIDE(SUM('table'[data1]), SUM('table'[data2]), 0), FILTER(ALL('calendar'), 'calendar'[date] <= 'calendar'[date]))

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

Hello @amitchandak ,

Thank you for your reply.

 

Although I can get correct value from these 2 Measure.

 

Measure1 =
VAR tm = CALCULATE(SUM('table'[data1]), FILTER(ALL('calendar'), 'calendar'[date] <= 'calendar'[date]))
return
DIVIDE('tm', 'table'[NumberofDays], 0)

 

Measure2 =
VAR tm = CALCULATE(SUM('table'[data2]), FILTER(ALL('calendar'), 'calendar'[date] <= 'calendar'[date]))
return
DIVIDE('tm', 'table'[NumberofDays], 0)

 

 

But when I try to compare them, I get all same value on Table visual.
MeasureResult = DIVIDE('table'[Mesaure1], 'table'[Measure2], 0)

Almost there, please give me advice?

Thank you,

@PbiCeo - We should probably back-up. Post sample data and expected result. It has proven to be the absolute quickest way of resolving problems for all of recorded time on these forums. 

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@PbiCeo - This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for your reply.

Is there any way to do with minimum change from my code?
Thanks,

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.