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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kleigh
Resolver III
Resolver III

Measure with static value causes relationship to explode

For an export table, I need some columns with fixed values (same for each row). So I created a measure like

Date Requested = FORMAT(NOW(), "yyyy-mm-dd")

This worked just fine when I had the one table. When I added a second table, it cross-joined and added all possible rows from the second table. If I make the measure do a little more work, it works as expected:

Key Count = DISTINCTCOUNT('Table A'[Key])

This happens in a minimal testcase. 
kleigh_0-1712928049777.png ... kleigh_1-1712928072713.png  ... kleigh_2-1712928139852.png

 kleigh_3-1712928175479.png

 

Why is it expanding the join like this and how do I stop it?

1 ACCEPTED SOLUTION
Sergii24
Super User
Super User

Hello @kleigh, your relationship is defining the way of interaction between excisting pair of values (such as 1-A-AAA), but there are also those "non-existing" (such as 1-A-BBB). You don't see unexisting values as long as you don't call a measure to show them.

Let's take a look at your measure: 

Date Requested = FORMAT(NOW(), "yyyy-mm-dd")

As you can see, it has nothing to do with your data, so technically its result exists for any combination (including those "unexisting").

I've added other 2 measures to show you how you can control the desired result:

Combination exists = DISTINCTCOUNT( 'Table A'[Key] )
Combination doesn't exist = 
    IF(
        DISTINCTCOUNT( 'Table A'[Key] ) > 0,
        BLANK(),
        1
    )

 

Sergii24_0-1712932168807.png

By keeping on the visual only measure "Combination exists", you can get all existing and currently selected pairs (to see all pairs whatever filters applied, you can use ALL() ).

Sergii24_1-1712932243545.png

I hope it helps!




 

View solution in original post

2 REPLIES 2
Sergii24
Super User
Super User

Hello @kleigh, your relationship is defining the way of interaction between excisting pair of values (such as 1-A-AAA), but there are also those "non-existing" (such as 1-A-BBB). You don't see unexisting values as long as you don't call a measure to show them.

Let's take a look at your measure: 

Date Requested = FORMAT(NOW(), "yyyy-mm-dd")

As you can see, it has nothing to do with your data, so technically its result exists for any combination (including those "unexisting").

I've added other 2 measures to show you how you can control the desired result:

Combination exists = DISTINCTCOUNT( 'Table A'[Key] )
Combination doesn't exist = 
    IF(
        DISTINCTCOUNT( 'Table A'[Key] ) > 0,
        BLANK(),
        1
    )

 

Sergii24_0-1712932168807.png

By keeping on the visual only measure "Combination exists", you can get all existing and currently selected pairs (to see all pairs whatever filters applied, you can use ALL() ).

Sergii24_1-1712932243545.png

I hope it helps!




 

Thanks, I was able to adapt this slightly:

Date Requested FIXED = SWITCH(DISTINCTCOUNT('Table A'[Key]),
BLANK(),BLANK(),
1, FORMAT(NOW(), "yyyy-mm-dd"),
"--")

This seems to be working, and gives a bonus check that it has been used in the correct context. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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