Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Dear all,
I have a production table with several columns, I want to find out the average egg production of last 12 days.
I have written the following code, but the result giving the data of all month and year. what is the problem
EggProductionOfLast12Days := CALCULATE ( AVERAGE ( FactProductionData[Egg Prod#Qty] ), FILTER ( FactProductionData, FactProductionData[Date] <= LASTDATE ( FactProductionData[Date] ) && FactProductionData[Date] >= LASTDATE ( FactProductionData[Date] ) - 12 ) )
Hi @arifulice,
Try this
=CALCULATE(AVERAGE(FactProductionData[Egg Prod#Qty]),DATESBETWEEN(Calendar[Date],MIN(Calendar[Date])-11,MAX(Calendar[Date])))
Hope this helps.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHello MFelix ,
After changing the lastdate by the followiung code, the result is remaining the same like giving the result for month Jan to December.
EggProductionOfLast12Days:=CALCULATE ( AVERAGE ( FactProductionData[Egg Prod#Qty] ), FILTER ( FactProductionData, FactProductionData[Date] <= LASTDATE ( FactProductionData[Date] ) && FactProductionData[Date] >= DATEADD(FactProductionData[Date], -12,DAY) ) )
Hi @arifulice
Another way
= CALCULATE ( AVERAGE ( FactProductionData[Egg Prod#Qty] ), DATESINPERIOD ( FactProductionData[Date], MAX ( FactProductionData[Date] ) - 11, 12, DAY ) )
After applying your DAX ,when i dropped the measure in pivot table the following error message is showing attached in photo
EggProduction:=CALCULATE ( AVERAGE ( FactProductionData[Egg Prod#Qty] ), DATESINPERIOD ( FactProductionData[Date], MAX ( FactProductionData[Date] ) - 11, 12, DAY ) )
I want to see the value of last 12 days but the below link giving the result of all month.please see the attached helow
User | Count |
---|---|
98 | |
90 | |
77 | |
71 | |
64 |
User | Count |
---|---|
114 | |
97 | |
95 | |
68 | |
65 |