Forum Discussion
Excel to DAX
I have a formula in excel which is calculating the percentage only if it has data for above 4 qtr
How can I convert this in a DAX expression using this logic of the formula
Reference image 1
Reference Image 2
Reference Image 3
And so on
=SUM(O14:O17)/SUM(D14:D17)
=SUM(O15:O18)/SUM(D15:D18)
=SUM(O16:O19)/SUM(D16:D19)
Measure I created
Output
14 Replies
- amitchandakSuper User
Nimai123 , Take rolling of Qtr
Rolling 4 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD(Table[Date],ENDOFMONTH(Sales[Sales Date]),-4,QUARTER))
HAs full QTR= CALCULATE(distinctcount(Date[Date),DATESINPERIOD(Table[Date],ENDOFMONTH(Sales[Sales Date]),-4,QUARTER))
Final Rolling 4 = if([HAs full QTR]=4,[Rolling 4 ],blank())
- MariuszCommunity Champion
Hi Nimai123
You can use DATESINPERIOD
https://docs.microsoft.com/en-us/dax/datesinperiod-function-daxbut you will need to adjust your model, add a date field to your table and Date dimension
https://www.youtube.com/watch?v=Pzn2B4laK9ABest Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn
- Greg_DecklerCommunity Champion
Can you post sample data as text so that we don't have to type it all in to recreate it?
Seems like you have a separate date table, so that is good for time intelligence functions. See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for. Using this technique you have explicit control over what dates you are calculating versus relying on time intelligence functions which don't always act the way you think they would.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008- Nimai123Post Patron
Sample Data
ATR 38,396,325 45,537,908 79,395,896 73,667,240 45,398,559 51,738,530 98,312,211 77,909,807 49,622,724 51,807,342 86,244,385 85,776,095 Renewed + open w. 29,452,554 36,612,309 66,404,172 62,861,772 38,341,826 42,568,263 81,921,358 63,845,235 41,543,047 44,173,611 74,205,335 73,457,709 FQ FY19-Q1 FY19-Q2 FY19-Q3 FY19-Q4 FY20-Q1 FY20-Q2 FY20-Q3 FY20-Q4 FY21-Q1 FY21-Q2 FY21-Q3 FY21-Q4