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 issue on months

animebuff_0-1735535047128.png

 

left side visual is what by default we get in PBI
what I need is left side visual without jan month because there is no data for jan month in fact table

 

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 

 

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

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
12 REPLIES 12
Ray_Minds
Continued Contributor
Continued Contributor

Hi @animebuff 

As I go through the measures provided by you.  You mention that it doesn’t work properly. Here is update and tested version of that measure you can use to solve your issue as you can see the Fig below.

Ray_Minds_0-1735638519650.jpeg

 

Ray_Minds_1-1735638519657.jpeg

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



nov month drill down values will not match,

it will show blank for values that needs to show 1

danextian
Super User
Super User

Hi @animebuff 

 

numerator=BLANK() && denominator=BLANK(),1,

This is telling DAX to return 1 when both the numerator and the denominator are both blank and this is true for January.

 

 numerator=BLANK(),0,

This is telling DAX to return 0 a when the numerator is blank  and this still is true for January. 0 value categories are not hidden so a column for January will still appear.

 

So why not just use

DIVIDE ( numerator, denominator )

Note: I am using DIVIDE as a best practice.

 





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.

but, in my scenario divide dax will not change the results

 

and jan month is not present in fact table so I need to avoid it 

what do you mean by ' in my scenario divide dax will not change the results"?

I tested this simple DIVIDE formula and it excludes january

danextian_0-1735557953960.png

 





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,

 

animebuff_1-1735566072358.png

 

but your logic will give correct results on month wise but if you drill down to region it will fail
bottom 2 ( 3 and 4 ) are based on the logic you gave

 

my expectation is I need to get 3rd (image) on month wise and 2rd (image) on region wise drill down
note: drill down done on nov month

You can use ISINSCOPE to check whether a column is the level in a hierarchy of levels.

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-1735624953960.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.
pallavi_r
Super User
Super User

Hi @animebuff ,

 

Is it possible for you to share your sample pbix file on the above. It would be easier to check the issue and share the fix.

Thanks,

Pallavi

is there a way to attach pbix file?

Hi @animebuff ,

Sorry,  google drive or dropbox link will do. Thanks, Pallavi

okay, will try to do it

Thank you

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.