Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
B_Rax
Frequent Visitor

How to Maintain Submission Window Context

I'm currently attempting to create a dax measure that seems simple, but is giving me a lot of trouble. I have a table populated with document submission dates. I want to have a table visual with a Date column and each cell will be colored based on being in or out of the submission window defined in the dax measure. I have a dax measure that works correctly when only the Date column is present in the table visual. However, if I add values from the submissions table (such as submission date or submitter name) it breaks down. Here are some screenshots of an example PBIX I created to isolate the issue:

The leftmost visual consists of the 'Calendar'[Date] column and [Submission Window] measure. 
The middle visual shows 'Calendar'[Date] with 'Submissions'[Submitter] and [Form ID]. This behaves as expected.
The rightmost visual shows values from 'Calendar' and 'Submissions' with theh [Submission Window] measure added. It seems the relationship between 'Calendar' and 'Submissions' has broke down and all values are pairing.

B_Rax_0-1731681279573.png


Here is the data model:

B_Rax_1-1731681533125.png

Date and Date Submitted are both Date data type. 'Calendar' is set as the date table using [Date].

This is the dax expression used (this is one of many iterations):

Submission Window = IF(SELECTEDVALUE('Calendar'[Weekday Num]) >= 1 && SELECTEDVALUE('Calendar'[Weekday Num]) <= 3, "On Time", "Late")
1 ACCEPTED SOLUTION
B_Rax
Frequent Visitor

I added a blank check field using this DAX:

Blank Check = 
     DISTINCTCOUNT('Submitted Documents'[Form ID]) & 
     IF(
          ISBLANK(SELECTEDVALUE('Submitted Documents'[Date Submitted])), 
          "No Submission", 
          " Submitted"
     )

The color formatting DAX is now:

Submission Window = 
VAR inWindow = 
    IF(
        SELECTEDVALUE('Calendar'[Weekday Num]) >= 1 && 
        SELECTEDVALUE('Calendar'[Weekday Num] ) <= 3, 
        TRUE(), 
        FALSE()
    )
VAR color = 
    SWITCH (
        TRUE(),
        inWindow, "Green",
        "Red"
    )

RETURN
    color

This leads to this result with some aggregation on Submitter:

B_Rax_0-1731692690543.png

It's starting to look much closer to what I'm trying to achieve. However, if I change "No Submission" to Blank(), which looks much nicer, the color drops again. To fix that I used "" instead of Blank(). I'll try to go with this compromise for now, but I'd love to hear if you or anyone else knows why my conditional formatting disappears when values on the many side of the relationship are included but are all blank:

B_Rax_1-1731692907570.png

 

Thank you!

 

View solution in original post

6 REPLIES 6
johnt75
Super User
Super User

I think the problem is because the measure will return a non-blank value regardless of anything in the submitted documents table, so all possible combinations return something.

Try

Submission Window =
IF (
    NOT ISEMPTY ( VALUES ( 'Submitted Documents'[Date Submitted] ) ),
    IF (
        SELECTEDVALUE ( 'Calendar'[Weekday Num] ) >= 1
            && SELECTEDVALUE ( 'Calendar'[Weekday Num] ) <= 3,
        "On Time",
        "Late"
    )
)
B_Rax
Frequent Visitor

This may be on the right track, but it does not fully solve the issue when I try to apply this to color formatting. For example, if I use my original dax as color formatting I can easily see the submission windows. With the current fix we lose color formatting on any date that didn't have a submission:

B_Rax_0-1731684504231.png

 



Not too familiar with the conditional formatting side of things. Is there an option to give it a colour if the value is blank ?

B_Rax
Frequent Visitor

It's possible. I created a new measure that works without checking 'Submitted Documents' for blanks. However, it still does not apply color to blank submission values. 

The new dax:

Submission Window = 
VAR inWindow = 
    IF(
        SELECTEDVALUE('Calendar'[Weekday Num]) >= 1 && 
        SELECTEDVALUE('Calendar'[Weekday Num] ) <= 3, 
        TRUE(), 
        FALSE()
    )
VAR color = 
    SWITCH (
        TRUE(),
        inWindow, "Green",
        "Red"
    )

RETURN
    color

 
New dax with blank check and alternative color if blank:

Submission Window = 
VAR inWindow = 
    IF(
        SELECTEDVALUE('Calendar'[Weekday Num]) >= 1 && 
        SELECTEDVALUE('Calendar'[Weekday Num] ) <= 3, 
        TRUE(), 
        FALSE()
    )
VAR color = 
    SWITCH (
        TRUE(),
        ISBLANK(SELECTEDVALUE('Submitted Documents'[Date Submitted])) = FALSE(), IF(inwindow, 
                "Green", "Red"),
        "Black"
    )

RETURN
    color

 

Both of the above measures have the same result:

B_Rax_0-1731687010500.png

 

In the second DAX I'm not sure if the ISBLANK() expression is always evaluating to FALSE() or if the coloring is being ignored all together since no rows are changed to black.

Easiest way to tell would be to create another measure in the visual which returns 

ISBLANK(SELECTEDVALUE('Submitted Documents'[Date Submitted]))
B_Rax
Frequent Visitor

I added a blank check field using this DAX:

Blank Check = 
     DISTINCTCOUNT('Submitted Documents'[Form ID]) & 
     IF(
          ISBLANK(SELECTEDVALUE('Submitted Documents'[Date Submitted])), 
          "No Submission", 
          " Submitted"
     )

The color formatting DAX is now:

Submission Window = 
VAR inWindow = 
    IF(
        SELECTEDVALUE('Calendar'[Weekday Num]) >= 1 && 
        SELECTEDVALUE('Calendar'[Weekday Num] ) <= 3, 
        TRUE(), 
        FALSE()
    )
VAR color = 
    SWITCH (
        TRUE(),
        inWindow, "Green",
        "Red"
    )

RETURN
    color

This leads to this result with some aggregation on Submitter:

B_Rax_0-1731692690543.png

It's starting to look much closer to what I'm trying to achieve. However, if I change "No Submission" to Blank(), which looks much nicer, the color drops again. To fix that I used "" instead of Blank(). I'll try to go with this compromise for now, but I'd love to hear if you or anyone else knows why my conditional formatting disappears when values on the many side of the relationship are included but are all blank:

B_Rax_1-1731692907570.png

 

Thank you!

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.