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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
WTAS80486
Helper IV
Helper IV

How to Calculate cumulative count from one table based on months in another table

Measure is:

 

COUNT() = COUNTX(FILTER(Table 1, Table 1[PM/CM] = "Corrective"

&& Table 1[Month Number(Failed Date)] <> BLANK()

&& Table 1[Month Name(Failed Date)] =MAX('Table 2[Month Name])),  Table 1[PM/CM])

 

‘Table 1’  filtered by asset no:

 

It has dec, Jan and June entries for this asset

 

 

It also has this column Table1[PM/CM]

 

Table 2 looks like this and has nov-jul entries

 

 

Now cumulative count has to be calculated Nov to Jul

 

Ankita80486_2-1660050624678.png

 

 

Ankita80486_3-1660050624680.png

 

 

So for Jan count should be 3 and march also 3.

 

Can anyone help!

 

 

2 ACCEPTED SOLUTIONS
SpartaBI
Community Champion
Community Champion

@WTAS80486 make sure you have the proper dimensions between the different facts and don't created a relationship between the facts themselves.
And create these measures:

COUNT(failures_month) V2 = 
COUNTROWS(
    FILTER(
        Workorder_with_assetdowntime_MTBF, 
        Workorder_with_assetdowntime_MTBF[PM/CM] = "Corrective" 
            && Workorder_with_assetdowntime_MTBF[Month Number(Failed Date)] <> BLANK()
    )
)

COUNT(failures_month) V2 Cummulative = 
VAR _max_date = max('Date'[Date])
VAR _max_peossible_date = MAX(Workorder_with_assetdowntime_MTBF[Failed Date New])
RETURN
CALCULATE(
    [COUNT(failures_month) V2], 
    'Date'[Date] <= _max_date && 'Date'[Date] <= _max_peossible_date
)

View solution in original post

Change this part:

IF(
    _max_date <= _max_peossible_date,
 
To this
 
IF(
EOMONTH(  _max_date, -1) <= _max_peossible_date,

View solution in original post

5 REPLIES 5
WTAS80486
Helper IV
Helper IV

@SpartaBI Its working! Thanks so much!

SpartaBI
Community Champion
Community Champion

@WTAS80486 make sure you have the proper dimensions between the different facts and don't created a relationship between the facts themselves.
And create these measures:

COUNT(failures_month) V2 = 
COUNTROWS(
    FILTER(
        Workorder_with_assetdowntime_MTBF, 
        Workorder_with_assetdowntime_MTBF[PM/CM] = "Corrective" 
            && Workorder_with_assetdowntime_MTBF[Month Number(Failed Date)] <> BLANK()
    )
)

COUNT(failures_month) V2 Cummulative = 
VAR _max_date = max('Date'[Date])
VAR _max_peossible_date = MAX(Workorder_with_assetdowntime_MTBF[Failed Date New])
RETURN
CALCULATE(
    [COUNT(failures_month) V2], 
    'Date'[Date] <= _max_date && 'Date'[Date] <= _max_peossible_date
)

Thanks @SpartaBI for the solution. You are so helpful!

@SpartaBI 

 

This measure:

 

COUNT(failures_month) V2 Cummulative =
VAR _max_date = max('dimDate'[Date])
VAR _max_peossible_date = calculate(max(MAX(Workorder_with_assetdowntime_MTBF[Date(Failed)]),MAX('Runhours_Total Hours_By Month'[Date(Start)])), REMOVEFILTERS(dimDate),  Workorder_with_assetdowntime_MTBF[PM/CM] = "Corrective"
            ,Workorder_with_assetdowntime_MTBF[Month Name(Failed Date)] <> BLANK())
RETURN
IF(
    _max_date <= _max_peossible_date,
    CALCULATE(
        [COUNT(failures_month) V2],
    'dimDate'[Date] <= _max_date
    )+0
)
 
 
Is not populating cumulative count for last month, JULY in this case, This last month is Date(start) from runhours_totalhours table. 
 
Ankita80486_1-1660074110061.png

Date(failed) from workorder_with_asset downtime table

 

Ankita80486_2-1660074177708.png

 

 

 

Change this part:

IF(
    _max_date <= _max_peossible_date,
 
To this
 
IF(
EOMONTH(  _max_date, -1) <= _max_peossible_date,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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