Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I created a measurement that averages the amount of rain in a day on a farm, now I would like to do the cumulative calculation, that is, the value of the next line is the sum of the previous lines
Solved! Go to Solution.
Your date_short column was of type text. It needs to be of type date. That is why my first version was failing. It will work if you use this to create that column instead of the LEFT([date], 9) you had:
Date_short = DATEVALUE([date])
I have created another version that wil work with the months. Note that I have gotten rid of the date hierarchy (which I would strongly discourage as it can be the hidden cause of many problems) and created a month column. It would be better to create a Year-Month column and better still to use a date table.
teste26/12 V2 =
VAR currentDate_ = MAX ( 'coperplan01 pluviometer_monitoring_list'[Date_short] )
VAR dates_ =
FILTER (
CALCULATETABLE (
DISTINCT ( 'coperplan01 pluviometer_monitoring_list'[Date_short] ),
ALLSELECTED (
'coperplan01 pluviometer_monitoring_list'[Date_short],
'coperplan01 pluviometer_monitoring_list'[Month]
)
),
[Date_short] <= currentDate_
)
RETURN
CALCULATE (
SUMX ( dates_, [Chuva Acumulada_] ),
ALLSELECTED (
'coperplan01 pluviometer_monitoring_list'[Date_short],
'coperplan01 pluviometer_monitoring_list'[Month]
)
)
See it all at work in the attached file (Page 3)
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Your date_short column was of type text. It needs to be of type date. That is why my first version was failing. It will work if you use this to create that column instead of the LEFT([date], 9) you had:
Date_short = DATEVALUE([date])
I have created another version that wil work with the months. Note that I have gotten rid of the date hierarchy (which I would strongly discourage as it can be the hidden cause of many problems) and created a month column. It would be better to create a Year-Month column and better still to use a date table.
teste26/12 V2 =
VAR currentDate_ = MAX ( 'coperplan01 pluviometer_monitoring_list'[Date_short] )
VAR dates_ =
FILTER (
CALCULATETABLE (
DISTINCT ( 'coperplan01 pluviometer_monitoring_list'[Date_short] ),
ALLSELECTED (
'coperplan01 pluviometer_monitoring_list'[Date_short],
'coperplan01 pluviometer_monitoring_list'[Month]
)
),
[Date_short] <= currentDate_
)
RETURN
CALCULATE (
SUMX ( dates_, [Chuva Acumulada_] ),
ALLSELECTED (
'coperplan01 pluviometer_monitoring_list'[Date_short],
'coperplan01 pluviometer_monitoring_list'[Month]
)
)
See it all at work in the attached file (Page 3)
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
You are my hero
hi @gelsonwj
try to create a measure like this:
this doesn't work for me, because the SUM() function only accepts a table, and in my case I have a measure that calculates the accumulated rain
Hi @gelsonwj
Can you share the code of your current measure? It can probably be modified slightly to get to the cumulative.
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Ok
Try this measure that uses the one you have:
Chuva Acumulada_Cumul =
VAR currentDate_ = SELECTEDVALUE ( 'coperplan01 pluviometer_monitoring_list'[Date_short] )
VAR dates_ =
FILTER (
CALCULATETABLE (
DISTINCT ( 'coperplan01 pluviometer_monitoring_list'[Date_short] ),
ALLSELECTED ( 'coperplan01 pluviometer_monitoring_list'[Date_short] )
),
[Date_short] <= currentDate_
)
RETURN
SUMX ( dates_, [Chuva Acumulada_] )
I suspect your [Chuva Acumulada_] measure can be simplified to a large extent, but I would need to see a sample of the 'coperplan01 pluviometer_monitoring_list' table and an example based on it to be sure
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
i would like to have a result like this
this is the table. Each farm has its ID and a farm is composed of N rain gauges. In order to calculate the accumulated rain, it is necessary to make an average of each day, of all the rain gauges of a farm X, and day N is added to day N+1... "quantity" is the amount of rain in mm
Does the suggestion in my previous post work?
If not I would need more details as to where it does not and some sample datga, ideally a pbix t work on
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Did not work. Where can I send you the .pbix file?
You'd have to share here the URL to the file hosted elsewhere: Dropbox, Onedrive... or just upload the file to a site like tinyupload.com (no sign-up required).
Or share the URL it via PM if you prefer
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Can you paste the code in text, so that it can be copied, rather than on a screen cap?
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
24 | |
20 | |
15 | |
12 |
User | Count |
---|---|
55 | |
48 | |
43 | |
19 | |
18 |