top of page

Common DAX functions

Updated: Oct 14, 2024

Australian Sales Tax =
IF(
    SELECTEDVALUE(Customer[Country-Region]) = "Australia",
    [Sales] * 0.10
)

DATEADD

Actuals LY (,000) = 
CALCULATE( [Actuals (,000)], DATEADD( Dates[Date], -1, YEAR ) )

SWITCH

Annual Amounts = 
VAR CurrentItem = SELECTEDVALUE( 'Income Statement Template'[Items - Normalized] )

VAR Actuals = SWITCH( TRUE(),
    CurrentItem = "Total Revenues", DIVIDE( [Revenues], 1000, 0 ),
    CurrentItem = "Total COGS", DIVIDE( [COGS], 1000, 0 ),
    CurrentItem = "Total Gross Profit", DIVIDE( [Gross Profit], 1000, 0 ),
    CurrentItem = "Gross Profit %", FORMAT( [Gross Profit Margin], "0.00%" ),
    CurrentItem = "Total Other Expenses", DIVIDE( [Expenses], 1000, 0 ),
    CurrentItem = "Total Net Profit", DIVIDE( [Net Profit], 1000, 0 ),
    CurrentItem = "Net Profit %", FORMAT( [Net Profit Margin], "0.00%" ),
        CALCULATE( [Actuals (,000)],
            FILTER( 'Income Statement', 'Income Statement'[Items] = CurrentItem ) ) )

RETURN
Actuals

SAMEPERIODLASTYEAR

Profits LY = 
CALCULATE( 
    [Total Profits] , 
        SAMEPERIODLASTYEAR( Dates[Date] ))

DATESYTD

Sales Year to Date = 
CALCULATE( 
    [Total Sales] , 
        DATESYTD( Dates[Date] ) )

FORMAT

= FORMAT( 12345.6789, "0.00")
= FORMAT( 12345.67, "General Number")  
= FORMAT( 12345.67, "Currency")  
= FORMAT( 12345.67, "Fixed")  
= FORMAT( 12345.67, "Standard")  
= FORMAT( 12345.67, "Percent")  
= FORMAT( 12345.67, "Scientific")
= FORMAT( dt"2020-12-15T12:30:59", BLANK(), "en-US" )  
= FORMAT( dt"2020-12-15T12:30:59", BLANK(), "en-GB" )  
= FORMAT( dt"2020-12-15T12:30:59", "mm/dd/yyyy", "en-GB" )

TREATAS

CALCULATE(
    SUM(Sales[Amount]), 
    TREATAS(           
    VALUES(DimProduct1[ProductCategory]),
    DimProduct2[ProductCategory])
)

DATEDIFF

DATEDIFF(<Date1>, <Date2>, <Interval>)

Comments


  • LinkedIn
Never Miss a Post. Subscribe Now!
bottom of page