Forum Discussion
Daily total between two dates
- 6 years ago
hi Anonymous
For your case, you could use a matrix visual to get it.
Just drag date field into columns of matrix visual, and for slicer, if you just want to choose two date, you'd better use list for this slicer.
and if you want use range of a slicer(Between), you could create a measure as below to get it:
Measure = var ascdaterank =RANKX(ALLSELECTED('Table'[Date]),CALCULATE(MAX('Table'[Date])),,ASC) var descdaterank =RANKX(ALLSELECTED('Table'[Date]),CALCULATE(MAX('Table'[Date])),,DESC) return IF(ascdaterank=1||descdaterank=1,CALCULATE(SUM('Table'[Cost])))Result:
and here is sample pbix file, please try it.
Regards,
Lin
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.
Thank you for the advice; I have tried to match your request and please let me know additional requests.
1. Power BI Usage_Details Table
| Subscription_Name | Cost | Year | Month | Day |
| Name_1 | 2.24643651 | 2020 | May | 1 |
| Name_2 | 32.3810413 | 2020 | May | 1 |
| Name_3 | 20.0792305 | 2020 | May | 1 |
| Name_4 | 4.84115459 | 2020 | May | 1 |
2. Desired Result
| SubscriptionName | Cost | Year | Month | Day | Cost_2 | Year_2 | Month_2 | Day_2 |
| Name_1 | 2.246436511 | 2020 | May | 1 | 2.24643651 | 2020 | May | 17 |
| Name_2 | 32.23771044 | 2020 | May | 1 | 32.3810413 | 2020 | May | 17 |
| Name_3 | 20.09001796 | 2020 | May | 1 | 20.0792305 | 2020 | May | 17 |
| Name_4 | 4.881155111 | 2020 | May | 1 | 4.84115459 | 2020 | May | 17 |
3. I would like the flexibility of selecting any two dates. I do not want, for example, to select the first date and then a relative second date (i.e., 1 week before, 1 week after).