You are on page 1of 9

Total sales is measure which is calculated using the DAX function

Creating duplicate table:

Table tools  New table

Newtable_name = <existing table>

Creating date table:

Table tools  New table

Dimdate_Shipdate = CALENDAR(date(2020,1,1) date(2021,1,1))

This will create the date column with values between 2020 to 2021 till January 1 St.

You can derive values out of this column using year().


Year()

Row VS filter context:

Row context performs calculations for each row and returns the result.
SUMX(<table>, <expression>)

First filter context is applied based on the visual selection and reduced to the corresponding table.
finally row context is applied.

Filter context applies the filters before the table is going to use.

Calculate() :

This evaluates expression in context modified by filters.


US sales measure
If you want to ignore the filter context and then include all() in calculate() in below measure.

Below we can calculate contribution of company with respect to all country sales and calculated the
percentage contribution.
DAX functions:
MAX:

Returns the largest value in a column, or between two scalar expressions.


MAX(<column>)
MAX(<expression1>, <expression2>)

 When comparing two expressions, blank is treated as 0 when comparing.


That is, Max(1, Blank() ) returns 1, and Max( -1, Blank() ) returns 0. If both
arguments are blank, MAX returns a blank. If either expression returns a
value which is not allowed, MAX returns an error.

 TRUE/FALSE values are not supported. If you want to evaluate a column


of TRUE/FALSE values, use the MAXA function.

MAXX:

Calculates expression for each row of a table and returns the largest value.
MAXX(<table>,<expression>)

 The table argument to the MAXX function can be a table name, or an


expression that evaluates to a table. The second argument indicates the
expression to be evaluated for each row of the table.
Numbers, texts and dates are counted.

Logical values and blank values are skipped.

MAXA:

Consider numbers and dates. Logical values true as 1 and false as 0. Ignores
blank values

MAXA(<column>)

In below, filter function returns the table with salesamount > 1000 and

on top of that MAXX calculates maximum sales for corresponding products/categories.

Today Vs NOW

Now gives current date with time

Today gives current date


Datediff gives difference between ship date and order date.

You might also like