Open Maruthipbi opened 6 months ago
Power BI DAX CODE FOR REVIEW:
Calender Table:
Calendar = ADDCOLUMNS ( CALENDAR (), "Year", YEAR ( [Date] ), "Month Number", MONTH ( [Date] ), "Month Name", FORMAT ( [Date], "MMMM" ), "Quarter", QUARTER ( [Date] ), "Day of Week Number", WEEKDAY ( [Date] ), "Day of Week Name", FORMAT ( [Date], "dddd" ), "Day of Month", DAY ( [Date] ), "Week of Year", WEEKNUM ( [Date], 2 ) )
SalesBreakdownByCountry = SUMMARIZE( 'Sales', 'Sales'[Country], "Total Sales", SUM('Sales'[Sales Amount]) )
Sales = Sales_Table[price_per_kg]*Sales_Table[weight_kg]
Vloumes = SUM(Sales_Table[weight_kg])
Week Over Week Comparison = VAR CurrentWeekSales = CALCULATE(SUM(Sales_Table[Sales]), 'Sales_Table'[Weeknum] = MAX('Sales_Table'[Weeknum])) VAR PreviousWeekSales = CALCULATE(SUM(Sales_Table[Sales]), 'Sales_Table'[Weeknum] = MAX('Sales_Table'[Weeknum]) - 1) RETURN IF(ISBLANK(PreviousWeekSales), BLANK(), (CurrentWeekSales - PreviousWeekSales) / PreviousWeekSales)
Weeknum = WEEKNUM(Sales_Table[date])
Coutry breakdownsales.zip
Power BI DAX CODE FOR REVIEW:
Calender Table:
Calendar = ADDCOLUMNS ( CALENDAR (), "Year", YEAR ( [Date] ), "Month Number", MONTH ( [Date] ), "Month Name", FORMAT ( [Date], "MMMM" ), "Quarter", QUARTER ( [Date] ), "Day of Week Number", WEEKDAY ( [Date] ), "Day of Week Name", FORMAT ( [Date], "dddd" ), "Day of Month", DAY ( [Date] ), "Week of Year", WEEKNUM ( [Date], 2 ) )
SalesBreakdownByCountry = SUMMARIZE( 'Sales', 'Sales'[Country], "Total Sales", SUM('Sales'[Sales Amount]) )
Sales = Sales_Table[price_per_kg]*Sales_Table[weight_kg]
Vloumes = SUM(Sales_Table[weight_kg])
Week Over Week Comparison = VAR CurrentWeekSales = CALCULATE(SUM(Sales_Table[Sales]), 'Sales_Table'[Weeknum] = MAX('Sales_Table'[Weeknum])) VAR PreviousWeekSales = CALCULATE(SUM(Sales_Table[Sales]), 'Sales_Table'[Weeknum] = MAX('Sales_Table'[Weeknum]) - 1) RETURN IF(ISBLANK(PreviousWeekSales), BLANK(), (CurrentWeekSales - PreviousWeekSales) / PreviousWeekSales)
Weeknum = WEEKNUM(Sales_Table[date])