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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
animebuff
Helper I
Helper I

dax logic not working on 2 levels

animebuff_1-1735566072358.png

 

my fact table has 2 months ( nov, dec) data & month table has 3 months data ( nov, dec, jan)

since fact is only having 2 months data, the metric is expected to only show 2 months data

in my case, it shows 3 months data 

 

the logic I have written is if numerator and denominator is blank then 1, if numerator alone blank then 0 if numerator & denominator are not blank then numerator/denominator

 

month and region drill down is showing the expected value the only issue is I get an extra jan month data 

 

the image show drilldown of nov month

I need to get 3rd image on month wise & 2rd image on Nov drilldown 

 

whatever I try I either get 1 2 combination or 3 4 combination not 3 2 combination 

-----------------------------------------------------------------------------------------------------------------------

dax:

 

Measure =
var numerator = CALCULATE(DISTINCTCOUNT('S rate'[success]),'S rate'[inclusion flag]="Y")
var denominator = DISTINCTCOUNT('S rate'[success])
return
SWITCH(
    TRUE(),
    numerator=BLANK() && denominator=BLANK(),1,
    numerator=BLANK(),0,
    numerator/denominator
)
-----------------------------------------------------------------------------------------------------------------------
 
tables:
 
s rate 
mkregioninclusion flagsuccess
1apacy95
1europen85
1lay91
1nan97
1african88
1australian95
1apacy93
2europey94
2lan89
2nan88
2african99
2australian80
2uaen90

 

region

region
apac
europe
la
na
africa
australia
uae

 

month

mkm
1nov
2

dec

3jan
1 ACCEPTED SOLUTION
danextian
Super User
Super User

I replied to your original post.

Measure02 = 
VAR numerator =
    CALCULATE (
        DISTINCTCOUNT ( 'S rate'[success] ),
        'S rate'[inclusion flag] = "Y"
    )
VAR denominator =
    DISTINCTCOUNT ( 'S rate'[success] )
VAR _pct =
    DIVIDE ( numerator, denominator )
RETURN
    IF ( ISINSCOPE ( region[region] ), _pct + 0, _pct )

 

danextian_0-1735626176028.gif

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Ashish_Mathur_0-1735785252526.pngAshish_Mathur_1-1735785262404.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
danextian
Super User
Super User

I replied to your original post.

Measure02 = 
VAR numerator =
    CALCULATE (
        DISTINCTCOUNT ( 'S rate'[success] ),
        'S rate'[inclusion flag] = "Y"
    )
VAR denominator =
    DISTINCTCOUNT ( 'S rate'[success] )
VAR _pct =
    DIVIDE ( numerator, denominator )
RETURN
    IF ( ISINSCOPE ( region[region] ), _pct + 0, _pct )

 

danextian_0-1735626176028.gif

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian thanks for the reply

everything is perfect 👌 but
numerator = blank && denominator = blank,1
numerator alone is blank then 0

this part didn't work, for both cases it shows 0

 

for nov month uae also has 1 because for nov uae has no numerator or denominator 

I'm confused. Wasnt your goal to not show a month when it had no data but still show all regions when drilled down?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
anmolmalviya05
Super User
Super User

Hi @animebuff, Please try below measure:

Measure =
VAR numerator = CALCULATE(
DISTINCTCOUNT('S rate'[success]),
'S rate'[inclusion flag] = "Y"
)
VAR denominator = DISTINCTCOUNT('S rate'[success])
RETURN
IF(
numerator = BLANK() && denominator = BLANK(),
BLANK(),
SWITCH(
TRUE(),
numerator = BLANK(), 0,
numerator / denominator
)
)

@anmolmalviya05 thanks for the reply

numerator = BLANK() && denominator = BLANK() needs to be 1 not blank

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.