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 guys,
I want to make a chart in power bi desktop that has this data:
2014 total sales
2015 total sales
2016 total sales
YTD 2016 YTD sales
YTD 2017 YTD sales
so one solution is to make a table made out of measures (2014, 2015, YTD 2016, ytd 2017) and its values in other column, so I can then put values in chart and labels on axis.
Can you help me write a dax formula for such a table?
Or can you suggest a chart solution?
Problem is, if I stach measures in values on a chart, I get no labels on axis and it looks ugly 🙂
thanks for help!
Solved! Go to Solution.
Hi @AgencyPowerBi ,
By my test , the following measures you can have a try.
Year = YEAR(Table1[Date])
YTD 2017 = CALCULATE(SUM(Table1[ Sales]),DATESYTD('Date'[Date]))
YTD 2016 = CALCULATE(SUM(Table1[ Sales]),SAMEPERIODLASTYEAR('Date'[Date]),FILTER(Table1,Table1[Year] = 2016))
Sum Year = SUM(Table1[Year])
2016 =
IF(Table1[Sum Year] = 2016,
CALCULATE (
SUM ( Table1[ Sales]),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Year] = 2016
)
))
2015 =
IF(Table1[Sum Year] = 2015,
CALCULATE (
SUM ( Table1[ Sales]),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Year] = 2015
)
))
2014 =
IF(Table1[Sum Year] = 2014,
CALCULATE (
SUM ( Table1[ Sales]),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Year] = 2014
)
))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @AgencyPowerBi ,
By my test , the following measures you can have a try.
Year = YEAR(Table1[Date])
YTD 2017 = CALCULATE(SUM(Table1[ Sales]),DATESYTD('Date'[Date]))
YTD 2016 = CALCULATE(SUM(Table1[ Sales]),SAMEPERIODLASTYEAR('Date'[Date]),FILTER(Table1,Table1[Year] = 2016))
Sum Year = SUM(Table1[Year])
2016 =
IF(Table1[Sum Year] = 2016,
CALCULATE (
SUM ( Table1[ Sales]),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Year] = 2016
)
))
2015 =
IF(Table1[Sum Year] = 2015,
CALCULATE (
SUM ( Table1[ Sales]),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Year] = 2015
)
))
2014 =
IF(Table1[Sum Year] = 2014,
CALCULATE (
SUM ( Table1[ Sales]),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Year] = 2014
)
))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
this is all good, but how to show it in Column chart or bar chart?
Not in the table, cause this is easy and I know how to do it.
This is what I need. But it is not possible, since only one variable can be present for such a chart.
please ignore the arrow 🙂
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 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |