Forum Discussion
Simplify the code
Hey,
Would you have an idea to simplify my dax calcul ?
I want to do this for a month, so it's more complicated.
6 Replies
- Greg_DecklerCommunity Champion
Anonymous Perhaps use MONTH and YEAR to get the month and year of your [Date] and then use a CALCULATE(SUM where the month and year of the [Date] equals those values? Hard to determine what exactly you are trying to do.
Sorry, having trouble following, can you post sample data as text and expected output?
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.- AnonymousNot applicable
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.
- Greg_DecklerCommunity Champion
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.