Calculating Age (duration or difference between two dates) in years, months and days in Power Query M Script


16-Jul turns out to be the birthday of Microsoft Power BI. Here I post a formula in M Script to calculate the age (i.e., duration or difference between two dates) in years, months and days: let Source= [ PowerBIBDay = #date(2014, 7, 16), Today = Date.From(DateTime.LocalNow()), BirthdayFactor = if Date.DayOfYear(PowerBIBDay)<Date.DayOfYear(Today) then 0 else 1, DayFactor... Continue Reading →

A magical Excel trick for flattening data copied from a PivotTable report in tabular layout into usable format


Here is a scenario that I come across sometime ago when I received an Excel file with some apparently messy data for further processing to generate another report. The data in the file appear similar to below screenshot. This data is self-explanatory. It’s the sales in units and dollars of each product under each product... Continue Reading →

Up ↑