Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I cannot find a solution for a probably very simple question. I have a table with an absolute measure of a utility counter with the timestamp when it was measured e.g
The key is that the measured value always goes up. What I would like to do is to find out information about the consumption eg how much has been consumed this month, what is the difference between months, average consumption per day etc. The timestamps are quite random and some might be missing.
Hi @isidnis
Probably the easiest is to create an additional calculated column with the day only (i.e., discarding the time) :
DayColumn = INT(Table1[Timestamp])
and make the new column type date. Then create a standard date table and you'll be able to set up many of the things you're describing easily. For instance, average consumption per day:
1. Set Table1[DayColumn] in the rows of a matrix visual
2. Create a measure and place it on the matrix:
AverageMeasure = AVERAGE(Table1[Measure])
Thanks a lot for your answer, my problem is that the measure is an absolute value of a counter. So the average consumption per day would be (Value at the end of the day 1 - Value at the beginning of the day 1) +(Value at the end of the day 2 - Value at the beginning of the day 2)...... / (Number of days with data)
It would help and save us time if you described in detail what you need from the beginning, like you've done now. You can then create a measure and place it in a card visual (still using the new calculated column described earlier):
Measure2 = AVERAGEX ( DISTINCT ( Table1[DayColumn] ), VAR ValBeginDay_ = CALCULATE ( MIN ( Table1[Measure] ) ) VAR ValEndDay_ = CALCULATE ( MAX ( Table1[Measure] ) ) RETURN ValEndDay_ - ValBeginDay_ )
Sorry about the lack of info I am pretty new in all this area:)
I am going to try to be more specific. The table I have has actually 3 columns deviceid:that identifies the utility counter, timestamp of the measure and absolute measure of the counter that is a number that goes up everytime a user consumes electricity.
What I want to achieve, (your last formula didn´t work) is something like:
I was thinking about having a column with differential values of each day,
DAY CONDUMPTION = MAX(Table[Measure])-(CALCULATE(MAX(Table[Measure]),PREVIOUSDAY(Table[DayColumn]))
But it doesn´t work either.
Sorry again for the misunderstanding
You should create a fact table that will hold each day for each deviceid and you should linearly *interpolate* the consumption for each day. Then you'll be able to EASILY calculate consumption for any period of time.
If you don't do it the way I'm saying, you'll be struggling with DAX making it more complex and slower than it should be. In other words, the granularity of your fact should be the day, not days with gaps.
You can create the fact table using Power Query (M). It should not be difficult. Remember: the key to a simple and correct model is LINEAR INTERPOLATION.
Best
D.
Thanks for your help. Probably out of my skill set to do linear interpolation on power query. I have been able to get a table with only one measure per day but not sure how to get a column that has the incremental value on power query. I have been able to do it with a measure.
User | Count |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
27 | |
13 | |
11 | |
9 | |
6 |