Posts

Showing posts from June, 2017

DAX : Calculate average for Last 4 weeks

Hi All if you have average measure and needs to calculate for last 4 weeks then create DAX like shown below using DATESINPERIOD function Average of last 4 weeks = CALCULATE([Average For Report Period],DATESINPERIOD('Date'[Day],LASTDATE('Date'[Week Ending]),-28,DAY)) Average of last 12 weeks = CALCULATE([Average For Report Period],DATESINPERIOD('Date'[Day],LASTDATE('Date'[Week Ending]),-84,DAY))

POWER BI DAX : Complex two layered Average Calculation

Image
Hi All we got a scenario where we have a table with daily granularity and we need to aggregate weekly taking denominator column MAX and numerator column relative SUM and create ratio (percentage). For aggregation above week we need to take SUM of denominator .so layer 1 within week and layer 2 above week format and we need to take averages for the percentage on both layers if you see the image , we need to represent data on weekly basis and  issue here is  [weekly freqency target] is present in all the records of the week in a table, in  above report each row represents weeks data ,so we have to take only one value from those 7 days , so here we need to take Max of that value Compliance %  = Reading towards Complaince/ weekly frequency target Another challange here is Reading towards complaince  may be greater than weekly frequency in those cases we need to consider only 100 % example               Reading towards compalince = 5  and weekly frequency Target = 1