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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Sonal27
Regular Visitor

Calculated Measure based on Month

I have a Opening Count Measure (Given Below). The Logic which I have applied is:

 

If you looking for the Opening Count for Jan-2017 then Merge1[Loggd_dt] should be before 01 Jan 2017 and Merge1[Cmplt_dt] values should be from 01 jan 2017 (The data is from year 2005 upto date and the logic is to be applied to overall data). I am taking this measure in a matrix(along with two other measures). I have also applied some slicer in the same page. My other two measures are changing according to the value selected in Slicer. But the measure given below is not changing according to slicer.

 

Summary.jpg

 

 

Opening Count = 
IF (
    HASONEVALUE ( DateTable[StartOfMonthDate] ),
    CALCULATE (
        [Count_rows],
        FILTER (
            ALL ( Merge1 ),
            (
                Merge1[LOGGD_DT]
                    < CALCULATE (
                        VALUES ( DateTable[StartOfMonthDate] ),
                        USERELATIONSHIP ( DateTable[Date], Merge1[LOGGD_DT] )
                    )
                    && Merge1[CMPLT_DT]
                        >= CALCULATE (
                            VALUES ( DateTable[StartOfMonthDate] ),
                            USERELATIONSHIP ( DateTable[Date], Merge1[CMPLT_DT] )
                        )
            )
        )
    )
)

 

Closed Count = 
CALCULATE (
    [Count_rows],
    USERELATIONSHIP ( DateTable[Date], Merge1[CMPLT_DT] ),
    Merge1[STATUS] = "CL"
)
InProcess Count = 
CALCULATE (
    [Count_rows],
    USERELATIONSHIP ( DateTable[Date], Merge1[LOGGD_DT] )
    )

Count_rows = COUNTROWS(Merge1)

Please help me with the same. 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Sonal27,

 

Please replace ALL with ALLSELECTED in measure [opening Count].

Opening Count = 
IF (
    HASONEVALUE ( DateTable[StartOfMonthDate] ),
    CALCULATE (
        [Count_rows],
        FILTER (
            ALLSELECTED ( Merge1 ),
            (
                Merge1[LOGGD_DT]
                    < CALCULATE (
                        VALUES ( DateTable[StartOfMonthDate] ),
                        USERELATIONSHIP ( DateTable[Date], Merge1[LOGGD_DT] )
                    )
                    && Merge1[CMPLT_DT]
                        >= CALCULATE (
                            VALUES ( DateTable[StartOfMonthDate] ),
                            USERELATIONSHIP ( DateTable[Date], Merge1[CMPLT_DT] )
                        )
            )
        )
    )
)

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Sonal27,

 

Please replace ALL with ALLSELECTED in measure [opening Count].

Opening Count = 
IF (
    HASONEVALUE ( DateTable[StartOfMonthDate] ),
    CALCULATE (
        [Count_rows],
        FILTER (
            ALLSELECTED ( Merge1 ),
            (
                Merge1[LOGGD_DT]
                    < CALCULATE (
                        VALUES ( DateTable[StartOfMonthDate] ),
                        USERELATIONSHIP ( DateTable[Date], Merge1[LOGGD_DT] )
                    )
                    && Merge1[CMPLT_DT]
                        >= CALCULATE (
                            VALUES ( DateTable[StartOfMonthDate] ),
                            USERELATIONSHIP ( DateTable[Date], Merge1[CMPLT_DT] )
                        )
            )
        )
    )
)

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.