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 am looking to create a chart that shows totals by various date periods, such as Yesterday, Last Month, Month-to-Date (MTD), and Year-to-Date (YTD), etc. I started by making different measures for each of these time periods and putting them in a matrix with the desired category (payment type), but I have yet to figure out how to have the category to display across the columns and the time periods on the rows in a succinct way. Any suggestions would be appreciated!
Desired output:
Example of the measure calculations:
Yesterday = CALCULATE(SUM(payments[amount])
,FILTER(payments
,payments[pay_date]=TODAY()-1
)
)
Solved! Go to Solution.
Hi, @jpshepard
According to your description, you want to "Matrix of measures by different date periods, displayed by category".
Here are the steps you can refer to :
(1)This is my test data:
(2)We need to create a dimension table like this and we do not need to create any relationship between tables.
(3)Then we can create a measure like this:
Measure = var _row = MAX('Rows'[Column1])
var _today =SUMX( FILTER('Table' , 'Table'[pay_date] = TODAY()) , [amount])
var _yesterday = SUMX( FILTER('Table' , 'Table'[pay_date] = TODAY()-1) , [amount])
var _last_month =SUMX( FILTER('Table' , YEAR('Table'[pay_date]) = YEAR(TODAY()) && MONTH('Table'[pay_date]) = MONTH(TODAY())-1) , [amount])
var _MTD =SUMX( FILTER('Table' , YEAR('Table'[pay_date]) = YEAR(TODAY()) && MONTH('Table'[pay_date]) = MONTH(TODAY()) && 'Table'[pay_date]<= TODAY()) ,[amount])
var _YTD =SUMX( FILTER('Table' , YEAR('Table'[pay_date]) = YEAR(TODAY()) && 'Table'[pay_date]<= TODAY()) , [amount])
return
SWITCH(_row,
"Today",_today,
"Yesterday",_yesterday,
"Last Month" , _last_month,
"MTD" , _MTD,
"YTD",_YTD
)
(4)Then we can put the fields we need on the matrix visual and we can cort [Column1] by [Column2], the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi, @jpshepard
According to your description, you want to "Matrix of measures by different date periods, displayed by category".
Here are the steps you can refer to :
(1)This is my test data:
(2)We need to create a dimension table like this and we do not need to create any relationship between tables.
(3)Then we can create a measure like this:
Measure = var _row = MAX('Rows'[Column1])
var _today =SUMX( FILTER('Table' , 'Table'[pay_date] = TODAY()) , [amount])
var _yesterday = SUMX( FILTER('Table' , 'Table'[pay_date] = TODAY()-1) , [amount])
var _last_month =SUMX( FILTER('Table' , YEAR('Table'[pay_date]) = YEAR(TODAY()) && MONTH('Table'[pay_date]) = MONTH(TODAY())-1) , [amount])
var _MTD =SUMX( FILTER('Table' , YEAR('Table'[pay_date]) = YEAR(TODAY()) && MONTH('Table'[pay_date]) = MONTH(TODAY()) && 'Table'[pay_date]<= TODAY()) ,[amount])
var _YTD =SUMX( FILTER('Table' , YEAR('Table'[pay_date]) = YEAR(TODAY()) && 'Table'[pay_date]<= TODAY()) , [amount])
return
SWITCH(_row,
"Today",_today,
"Yesterday",_yesterday,
"Last Month" , _last_month,
"MTD" , _MTD,
"YTD",_YTD
)
(4)Then we can put the fields we need on the matrix visual and we can cort [Column1] by [Column2], the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Aniya, thank you for this wonderful response! It worked perfectly. If you get a chance, do you know how you would also add the # of payments for the time period as well? Like so:
Absolutely no worries if you don't get a chance to look at this. You already helped me so much! Really appreciate it.
Aha I figured it out - I made another measure just like the one you demonstrated, but this time using COUNTX in place of the SUMX. Thank you for showing me the way!
Hi, @jpshepard
Glad you solved the problem, we will do our best to answer your questions. If sometimes you forget or omit it for some reason, you can also open a new case and post it to us, we will try our best to help you!
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
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 |
---|---|
109 | |
106 | |
88 | |
75 | |
66 |
User | Count |
---|---|
125 | |
114 | |
98 | |
81 | |
73 |