Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Have a Power BI model that contains the following tables:
Sales11 (Sales_ID, DateID, sales_amount)
Date11 (DateID, Date, Month, week, Year)
The tables have a relationship. Date is marked as a date table in the Power BI model.
You need to create a measure to calculate the sales for the last 12 months.
Which DAX formula should you use?
1. CALCULATEx(SUM(sales11[sales_amount]) DATESYTD (‘Date11’ [Date]))
2. CALCULATE(SUM(sales11[sales_amount]), SAMEPERIODLASTYEAR (‘Date11’ [Date]))
3. SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date]))
4. SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),DATESYTD(‘Date11’[Date]))
Which one is correct 3 or 2? and explain why?
At one Place I found 2 is correct and at another place 3 is correct..
Got confused. Please help
Solved! Go to Solution.
@Anonymous wrote:Have a Power BI model that contains the following tables:
Sales11 (Sales_ID, DateID, sales_amount)
Date11 (DateID, Date, Month, week, Year)
The tables have a relationship. Date is marked as a date table in the Power BI model.
You need to create a measure to calculate the sales for the last 12 months.Which DAX formula should you use?
1. CALCULATEx(SUM(sales11[sales_amount]) DATESYTD (‘Date11’ [Date]))
2. CALCULATE(SUM(sales11[sales_amount]), SAMEPERIODLASTYEAR (‘Date11’ [Date]))
3. SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date]))
4. SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),DATESYTD(‘Date11’[Date]))
Which one is correct 3 or 2? and explain why?
At one Place I found 2 is correct and at another place 3 is correct..
Got confused. Please help
I tested this and correct ans is SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date]))
I have 3 years of sales data.
2013, 2014, 2015
Total sales= 15000 (sum of 3 years sales)
2013 Sales=4000
2014 Sales=5000
2015 Sales=6000
SUM(sales11[sales_amount]) Returns=15000
and CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date])) returns =9000
So
SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date]))=15000-9000=6000
@Anonymous wrote:Have a Power BI model that contains the following tables:
Sales11 (Sales_ID, DateID, sales_amount)
Date11 (DateID, Date, Month, week, Year)
The tables have a relationship. Date is marked as a date table in the Power BI model.
You need to create a measure to calculate the sales for the last 12 months.Which DAX formula should you use?
1. CALCULATEx(SUM(sales11[sales_amount]) DATESYTD (‘Date11’ [Date]))
2. CALCULATE(SUM(sales11[sales_amount]), SAMEPERIODLASTYEAR (‘Date11’ [Date]))
3. SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date]))
4. SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),DATESYTD(‘Date11’[Date]))
Which one is correct 3 or 2? and explain why?
At one Place I found 2 is correct and at another place 3 is correct..
Got confused. Please help
I tested this and correct ans is SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date]))
I have 3 years of sales data.
2013, 2014, 2015
Total sales= 15000 (sum of 3 years sales)
2013 Sales=4000
2014 Sales=5000
2015 Sales=6000
SUM(sales11[sales_amount]) Returns=15000
and CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date])) returns =9000
So
SUM(sales11[sales_amount])-CALCULATE(SUM(sales11[sales_amount]),SAMEPERIODLASTYEAR(‘Date11’[Date]))=15000-9000=6000
Hi @Anonymous
You can use the below
Sales Rolling 12 months = CALCULATE( [Sales], DATESINPERIOD( 'Calendar'[Date], MIN('Calendar'[Date]) -1, -12, MONTH ) )
Regards,
Mariusz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Mariusz wrote:Hi @Anonymous
You can use the belowSales Rolling 12 months = CALCULATE( [Sales], DATESINPERIOD( 'Calendar'[Date], MIN('Calendar'[Date]) -1, -12, MONTH ) )Regards,
Mariusz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for your response.
This is a mockup question and need to select an ans from given list. Would you please provide your ans from given options?
Thanks again.
@Anonymous look at this post which gives you last 12 months sum
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous clearly not sure what you are asking here.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
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 | |
102 | |
84 | |
79 | |
68 |
User | Count |
---|---|
120 | |
110 | |
94 | |
81 | |
77 |