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.
Hi,
I have a slicer that groups dates into different periods.
For example one value in my slicer is called Period A which is the first week of february.
I created two measures that allows me to calculate the bounds for the previous week as such . Note that my transaction_date column is in datetime :
Start | End | Start -1 | End -1 | Revenue Current | Revenue -1 Week | |
Period A | 2/10/2021 2:00 AM | 2/12/2021 5:00 AM | 2/3/2021 2:00 AM | 2/5/2021 5:00 AM | $ 100.00 | $ 75.00 |
Period B | 2/20/2021 2:00 AM | 2/22/2021 5:00 AM | 2/13/2021 2:00 AM | 2/15/2021 5:00 AM | $ 150.00 | $ 100.00 |
Solved! Go to Solution.
You can use below measure to get the previous week total revenue. This should be easier.
Previous Total Revenue =
CALCULATE (
SUM ( AllPackages[revenue] ),
ALL ( AllPackages ),
DATESBETWEEN (
AllPackages[transaction_date],
[PreviousWeek_MIN],
[PreviousWeek_MAX]
)
)
For your original measure, I use COUNTROWS(_summary) to return the number of rows of _summary table and gets the blank result. So the _summary variable table doesn't get the result correctly.
To use your measure, you can modify it into the following one. This should work. The reason is that when you use [PreviousWeek_MIN] and [PreviousWeek_MAX] directly in the FILTER() function, it will be calculated according to the filtered table's current row, so it will always get the blank value.
Revenue -1 Week =
VAR _maxDate = [PreviousWeek_MAX]
VAR _minDate = [PreviousWeek_MIN]
VAR _summary =
SUMMARIZE (
FILTER (
ALL ( AllPackages ),
AllPackages[transaction_date] >= _minDate && AllPackages[transaction_date] <= _maxDate
),
AllPackages[transaction_date],
"Rev", SUM ( AllPackages[revenue] )
)
RETURN
SUMX ( _summary, [Rev] )
Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Please see my edited post ( i put my desired output ) .
My start-1 and End-1 columns works fine...
You can use below measure to get the previous week total revenue. This should be easier.
Previous Total Revenue =
CALCULATE (
SUM ( AllPackages[revenue] ),
ALL ( AllPackages ),
DATESBETWEEN (
AllPackages[transaction_date],
[PreviousWeek_MIN],
[PreviousWeek_MAX]
)
)
For your original measure, I use COUNTROWS(_summary) to return the number of rows of _summary table and gets the blank result. So the _summary variable table doesn't get the result correctly.
To use your measure, you can modify it into the following one. This should work. The reason is that when you use [PreviousWeek_MIN] and [PreviousWeek_MAX] directly in the FILTER() function, it will be calculated according to the filtered table's current row, so it will always get the blank value.
Revenue -1 Week =
VAR _maxDate = [PreviousWeek_MAX]
VAR _minDate = [PreviousWeek_MIN]
VAR _summary =
SUMMARIZE (
FILTER (
ALL ( AllPackages ),
AllPackages[transaction_date] >= _minDate && AllPackages[transaction_date] <= _maxDate
),
AllPackages[transaction_date],
"Rev", SUM ( AllPackages[revenue] )
)
RETURN
SUMX ( _summary, [Rev] )
Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Hello @RogerSteinberg ,
can you check the values of PreviousWeek_MIN and PreviousWeek_MAX?
they're working fine. i had put the measures in the table initially to check their values and they work as intended
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 |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |