Forum Discussion
Simplify the code
Hi, thanks for your answer.
The fact is that i need to do a weighted average on a month, (like what i did for the week). As you can see the second variable [Nombre de sessions cumulées par semaine] isn't affected by the date (dateadd).
To simplify i want to do exactely the same thing you can see on the screen with only function if it does exist.
Anonymous Again, not following. First, I don't see any variables (VAR statements) in your code. And where the weighted average comes into play is not clear. I would have never guessed that was a weighted average formula. Without example data and expected output, it's hard to tell you what you need to do.
- Anonymous4 years agoNot applicable
I'll give you an example of what i actually want on excel.
There is the context :
I want to calculate the cumulative average time by session for the day 5 for example.
So I start by calculating each day, depending on the number of session, the average time by session and the cumulative session which is the sum of all the sessions.
Then to have my result i need to sum all of them,
I want to do the same on power bi on a month period for each day.
Example : if i choose the 1st February, i want the cumulative average time by session from 1st January to 1st February.
Sorry if i'm not clear enough, my english isn't the best.
Thanks for your answers.
- Greg_Deckler4 years agoCommunity Champion
Anonymous So typically I would do something like that this way:
Measure = VAR __Date = MAX(Dates[Date]) VAR __MonthAgo = DATE(YEAR(EOMONTH(__Date,-1)),MONTH(EOMONTH(__Date,-1)),DAY(__Date)) VAR __Table = ADDCOLUMNS(FILTER(ALL('Dates'),[Date]>=__MonthAgo && [Date]<=__Date),"__MyCalc",[your daily calculation goes here]) RETURN SUMX(__Table,[__MyCalc])- Anonymous4 years agoNot applicable
Thanks,
But what i ask for is to be able to use the cumulative session value of the day 5 for the calcul of all the other day. It need to be the same because it depend of the last day while the number of session and the average time is different each time. Let me know if i'm not clear enough.