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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
tarolz132q
New Member

Avg Balance DAX

Hi Folks,

I would like to measure the Avg coin balance for each day.

The challenge is to calculate only the newst coin balance for each date by USER_ID. if you notice, AF4FF96..... is shown twice! then when 05/26 is being calculated should be ignore the previous values.

tarolz132q_0-1654164939539.png

The result I would like to see that for the 05/25/22 - 98

The result I would like to see that for the 05/26/22 - 156

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
tarolz132q
New Member

Hi Guys, 

ill try to be more specific.

I would like to know what is the Coin balance in each time datapoint on my timeline.

It mean that for every date I would like to sum the last coin balance for each user_id untill that specific date and then divide by the number of players.

 

The outcome will be chart like that (disregard the values):

tarolz132q_0-1654600782509.png

The table is created in a way that in each date user id can appear only once!

my table:

DATEUSER_IDCOIN_BALANCE
6/1/2022572EDE3F07F53CDD800
6/1/20227FBF5E6AC11263811
6/1/2022CB086763FC1E3CC64
6/1/2022CE471B4692E6B8ED120
6/1/2022F40C6A78878151B392
6/2/2022233E855015CD343169
6/2/202273703E52FAD5609566
6/2/2022A6499BEE8D6C8A4048
6/2/2022CB086763FC1E3CC69
6/2/2022CE471B4692E6B8ED135

 

The measure results should be like that:

For day 1 it's easy calculation because I have 5 different users, i just sum up all 1017/5 = 203.4

For day 2 the calculation should include users that might be online in day 1 as well, but I want to take the last coin balance for each user_id then : 1220/8 = 152.5 (8 Different users included, 3 from day 1 and 5 from day 2)

 

 

 

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @tarolz132q ,

How to get the 05/26/22 - 156?

Create a measure.

Measure = VAR _DAYS= COUNTAX(FILTER(ALL('Table'),'Table'[date]=SELECTEDVALUE('Table'[date])),'Table'[date])
VAR SUM_=CALCULATE(SUM('Table'[COIN_BALANCE]),FILTER(ALL('Table'),'Table'[date]=SELECTEDVALUE('Table'[date])))
RETURN
SUM_/_DAYS

vpollymsft_0-1654499594683.png

If I have misunderstood your meaning, please provide more details with your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

Ashish_Mathur
Super User
Super User

Hi,

Please explain how you arrived at the ansers of 98 and 156.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

please see my new reply

 

 

Avg = 
var d = SELECTEDVALUE('Table'[DATE])
var a = calculatetable(SUMMARIZE('Table','Table'[USER_ID],"md",max('Table'[DATE])),'Table'[DATE]<=d)
var b = ADDCOLUMNS(a,"mb",var md=[md] return CALCULATE(sum('Table'[COIN_BALANCE]),'Table'[DATE]=md))
return  divide(sumx(b,[mb]),countrows(b),0)

 

lbendlin_0-1654626976358.png

 

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. I cannot use screenshots of your source data.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

please see my new reply

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.