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 have a request to build a column chart that shows the value of a measure for the last 7 days, last 28 days and last 365 days. Any suggestions on the best way to approach this? Below is an example of what I'm trying to reproduce (the line is the goal line)...
Solved! Go to Solution.
Hi @LisaK ,
According to my understanding ,you want to calculate sum of value based on different time periods, right?
You could use the following formula:
last7 =
CALCULATE (
SUM ( 'Last Period'[Value] ),
FILTER ( 'Last Period', DATEDIFF ( 'Last Period'[Date], NOW (), DAY ) <= 7 )
)
last28 =
CALCULATE (
SUM ( 'Last Period'[Value] ),
FILTER ( 'Last Period', DATEDIFF ( 'Last Period'[Date], NOW (), DAY ) <= 28 )
)
last365 =
CALCULATE (
SUM ( 'Last Period'[Value] ),
FILTER ( 'Last Period', DATEDIFF ( 'Last Period'[Date], NOW (), DAY ) <= 365 )
)
sum value =
SWITCH (
SELECTEDVALUE ( 'for X-axis'[last period] ),
"last 7", [last7],
"last 28", [last28],
"last 365", [last365]
)
My visualizations look like this:
Great ideas! Thanks everyone. I'll give them a try.
Hi @LisaK ,
According to my understanding ,you want to calculate sum of value based on different time periods, right?
You could use the following formula:
last7 =
CALCULATE (
SUM ( 'Last Period'[Value] ),
FILTER ( 'Last Period', DATEDIFF ( 'Last Period'[Date], NOW (), DAY ) <= 7 )
)
last28 =
CALCULATE (
SUM ( 'Last Period'[Value] ),
FILTER ( 'Last Period', DATEDIFF ( 'Last Period'[Date], NOW (), DAY ) <= 28 )
)
last365 =
CALCULATE (
SUM ( 'Last Period'[Value] ),
FILTER ( 'Last Period', DATEDIFF ( 'Last Period'[Date], NOW (), DAY ) <= 365 )
)
sum value =
SWITCH (
SELECTEDVALUE ( 'for X-axis'[last period] ),
"last 7", [last7],
"last 28", [last28],
"last 365", [last365]
)
My visualizations look like this:
You need a table with this structure
Index | Label |
7 | L7 |
28 | L28 |
365 | L365 |
Mark the index column as whole number
Then you can add a measure to that table that based on the index computes the values you need.
Sort the Label column by the Index column.
Now you can add the Label to the legend, and the measure result to the values.
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 |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |