Dyota's blog

DAX Cookbook

HTML only when one item is selected

Text (HTML) = 

VAR one = HASONEVALUE(table[itemid])

VAR _html = SUBSTITUTE(
    CONCATENATEX(
        table,
        "<p><b>" & [subject] & "</b></p>"
        & "<p>" & [description] & "</p>"
    ),
    UNICHAR(10),
    "<br>"
)

RETURN IF(
    one,
    _html, 
    ""
)

Cumulative count up to start of month

Cumulative Volume to Beginning of Month = 

VAR _startOfMonth = STARTOFMONTH('calendar'[Date])
VAR _thisDate = LASTNONBLANK('calendar'[Date], [Date])

RETURN 
    CALCULATE(
        [Measure],
        FILTER(
            ALL('calendar'),
            [Date] >= _startOfMonth
            && [Date] <= _thisDate
        )   
    )

#dax