简体   繁体   中英

Removing Blank Days from Power BI Chart

I have created a weekly request measure like so:

RequestsWeekly = var result= CALCULATE(
DISTINCTCOUNTNOBLANK(SessionRequests[RequestDateTime]),
FILTER('Date','Date'[WeekDate]=SELECTEDVALUE('DateSelector'[WeekDate],MAX('DateSelector'[WeekDate]))))+0

RETURN 
    IF ( NOT ISBLANK ( result ), result)

DateSelector is a standalone table (not connected to any other table in data model) that I have created for all the dates for a dropdown menu select for a Power BI Dasbboard. Unfortunately as there are less dates in the Date Selector table than the Date table, I get... Date table is the standard DATE table full of dates from 1970 to 2038. Date connects to Session Requests via a many to one relationships, single way filter. Session Requests is the main fact table.

在此处输入图像描述

I need to get rid of the blank row in my result set via DAX so it does not appear in my chart on the X axis. I have tried lots of different DAX combos like blank () and NOT ISBLANK. Do I need to create a table for the result set and then try to filter out the blank day there?

You should not check if the result is empty but if the VALUE ( Table[DayNameShort] ) exists for your current row context:

RequestsWeekly =
VAR result =
    CALCULATE (
        DISTINCTCOUNTNOBLANK ( SessionRequests[RequestDateTime] ),
        FILTER (
            'Date',
            'Date'[WeekDate]
                = SELECTEDVALUE (
                    'DateSelector'[WeekDate],
                    MAX ( 'DateSelector'[WeekDate] )
                )
        )
    ) + 0
RETURN
    IF (
        NOT ISBLANK (
            VALUE ( Table[DayNameShort] ) -- put here correct table name
        ),
        result
    )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM