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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
sivarajan21
Post Prodigy
Post Prodigy

Dax measure not considering the filter context

Hi,

 

I have created below dax:

 

Forecast Budget Unit (TimeSeries) = 
SUMX(
    VALUES( Calendar_[Month-Year] ),
    SUMX(
        VALUES( Points[DBName-Point_Id] ),
        VAR  _target = CALCULATE(
            AVERAGE( TargetTimeSeriesMonth[Dail Units] ),
            TargetTimeSeriesMonth[TargetType] = 1
        )
        VAR  _monthtarget = CALCULATE(
            SUM( TargetTimeSeriesMonth[Usage] ),
            TargetTimeSeriesMonth[TargetType] = 1
        )
        VAR  _noofdays = CALCULATE(
                COUNTROWS( Calendar_ ) * COUNTROWS( Points ),
                KEEPFILTERS( Points )
            )
        VAR  _nofinvdays = CALCULATE(
            COUNTROWS( DataInvoice ),
            KEEPFILTERS( Points )
            )
        VAR  _missing = _noofdays - _nofinvdays
        VAR  Result =
        IF(
            _missing = _noofdays,
            _monthtarget,
            _target * _missing
        )
        RETURN Result
    )

 

 

When I tested Dax measure, I found the below in the visual:

sivarajan21_0-1734025670254.png

 

I took the variables from Forecast Budget Unit (TimeSeries) dax and created 3 new separate measures to test it.

Found that missing dax is in negative (-62) and noofdays dax contains 31 days. This makes me doubt that I made some mistake in dax of noofdays. I am struggling to figure it out.


My requirement for :

noofdays dax - how many days are there in the given month-year for each point i.e at a point level

nofinvdays dax- how many invoice days are there for the given month year and point

missing dax - therefore how many days do i have missing

For example, April 2024 has 30 days,and a particular point might have 20 days in the invoice. so 30-20=10 missing days for that point in that month

therefore 10*average forecast rate(_target variable in above measure) = your forecast budget Unit (TimeSeries).


Above 3 dax variables form integral part of Forecast Budget Unit (TimeSeries). Could you please help me with logic?

PFA file here Portfolio Performance - v2.15 (1).pbix

 

Thanks in advance!

@marcorusso @Greg_Deckler @Ahmedx 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sivarajan21 

Based on your data, i am confused that in the first row , if the nofinvdays larger  than the days in july, should it return 0 because there are no missing days in that month.

and if you wan to the missing days >0, you can modify it to the following.

 

 

missing = abs([noofdays] - [nofinvdays])

 

 

 

Best Regards!

Yolo Zhu

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @sivarajan21 

Based on your data, i am confused that in the first row , if the nofinvdays larger  than the days in july, should it return 0 because there are no missing days in that month.

and if you wan to the missing days >0, you can modify it to the following.

 

 

missing = abs([noofdays] - [nofinvdays])

 

 

 

Best Regards!

Yolo Zhu

 

 

Thanks @Anonymous 

Its about the distincount of points for the noofdays measure and it works

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors