Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I am trying to create an expression to show total sales for prior YTD. My Sales and Date are in the same table. I do not have a separate date table. Is there an expression that will work for this scenario?
Table Name is Trades
Fields are Gross Amount and Trade Date
Solved! Go to Solution.
Hi @CJANE
You can create a Measure like the following.
LYTD =
var year=YEAR(MAX(Trades[Trade Date]))-1
return CALCULATE(SUM(Trades[Gross Amount]), FILTER(ALL(Trades),Trades[Trade Date]>=DATE(year,1,1)&&Trades[Trade Date]<=MAX(Trades[Trade Date])))
The result looks like this:
For more details, you can refer the attached pbix.
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @CJANE
You can create a Measure like the following.
LYTD =
var year=YEAR(MAX(Trades[Trade Date]))-1
return CALCULATE(SUM(Trades[Gross Amount]), FILTER(ALL(Trades),Trades[Trade Date]>=DATE(year,1,1)&&Trades[Trade Date]<=MAX(Trades[Trade Date])))
The result looks like this:
For more details, you can refer the attached pbix.
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You should not write any time intelligence function without a date table. The reason is that the time intelligence functions rely on a complete list of all days in the table to work. You can use the inbuilt date table if you like. Simply refer to it in locations where you must specify the date column, ie SAMEPERIODLASTYEAR(Trades[Date].[Date]). Note the extra .[Date]
Try any of the following 2 formulas:
LYTD = CALCULATE(SUM(Trades[Gross Amount]), SAMEPERIODLASTYEAR(Trades[Trade Date]))
LYTD = CALCULATE(SUM(Trades[Gross Amount]), DATEADD (Trades[Trade Date], -1, YEAR))
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 35 | |
| 31 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 39 | |
| 35 | |
| 23 |