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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nhuda
Helper I
Helper I

Cumulative calculation not returning data when no data for period selected

Hello,

I have some a table report where data is being displayed for the period selected (using date slider), and also cumulative data for each row groups. Cumulative calculation works fine except when there's no data for the period selected, as it should bring data from before the "From Date" in date slider.

nhuda_1-1714080681354.pngnhuda_2-1714080746435.png

So in the image above, we see cumulative data for Groups A,B and C. But when the slider date range selection is changed and there's no data for the period selected, the numbers disappear from the Cumulative columns like below (even though there's data that falls before the "From Date" in date slider:

nhuda_3-1714080934641.png

Here's the formula I am using: 

Cumulative Tested = 
VAR _select=SELECTEDVALUE('vw_PRBI_Report_WeldRepairStats'[Project])
VAR _pStartDate = MINX(FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),'vw_PRBI_Report_WeldRepairStats'[Project]=_select),[ProjectStartDate])
VAR _toDate=MAXX(ALLSELECTED('vw_PRBI_Report_WeldRepairStats'),'vw_PRBI_Report_WeldRepairStats'[TestedDate])
VAR __table = 
SUMMARIZE('vw_PRBI_Report_WeldRepairStats',[MaterialGroup],"__value",
    SUMX(
        FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]>=_pStartDate && 
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]<=_toDate &&
        'vw_PRBI_Report_WeldRepairStats'[Project]=_select && 
        'vw_PRBI_Report_WeldRepairStats'[MaterialGroup] = SELECTEDVALUE('vw_PRBI_Report_WeldRepairStats'[MaterialGroup]))
        ,ISBLANK([Tested]) || [Tested] = 0, 0, [Tested])
    )
)
RETURN
IF(
    HASONEVALUE(vw_PRBI_Report_WeldRepairStats[MaterialGroup]),
    SUMX(
        FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]>=_pStartDate && 
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]<=_toDate &&
        'vw_PRBI_Report_WeldRepairStats'[Project]=_select && 
        'vw_PRBI_Report_WeldRepairStats'[MaterialGroup] = SELECTEDVALUE('vw_PRBI_Report_WeldRepairStats'[MaterialGroup]))
        ,ISBLANK([Tested]) || [Tested] = 0, 0, [Tested])
    ),
    SUMX(__table,[__value])
)

@v-yangliu-msft helped me on the cumulative calculation and got ideas from @Greg_Deckler's link  https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/5...  for displaying Cumulative totals in Total Row for this issue.

Thank you,

nhuda

1 ACCEPTED SOLUTION

Hi @nhuda 

 

Please try this:

First of all, add a new table:

 

Table = CALENDAR(MIN('vw_PRBI_Report_WeldRepairStats'[TestedDate]),MAX('vw_PRBI_Report_WeldRepairStats'[TestedDate]))

 

Then I've made some changes to your original measure:

 

Cumulative Tested = 
VAR _Select = SELECTEDVALUE(vw_PRBI_Report_WeldRepairStats[Project])
VAR _pStartDate = MINX(FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),'vw_PRBI_Report_WeldRepairStats'[Project]=_Select),[ProjectStartDate])
VAR _toDate=MAXX(ALLSELECTED('Table'),'Table'[Date])

VAR __table = 
SUMMARIZE('vw_PRBI_Report_WeldRepairStats',[MaterialGroup],"__value",
    SUMX(
        FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]>=_pStartDate && 
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]<=_toDate &&
        'vw_PRBI_Report_WeldRepairStats'[Project]=_select && 
        'vw_PRBI_Report_WeldRepairStats'[MaterialGroup] = SELECTEDVALUE('vw_PRBI_Report_WeldRepairStats'[MaterialGroup]))
        ,IF(ISBLANK([Tested]) || [Tested] = 0, 0, [Tested])
    )
)
RETURN
IF(
    HASONEVALUE(vw_PRBI_Report_WeldRepairStats[MaterialGroup]),
    SUMX(
        FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]>=_pStartDate && 
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]<=_toDate &&
        'vw_PRBI_Report_WeldRepairStats'[Project]=_select && 
        'vw_PRBI_Report_WeldRepairStats'[MaterialGroup] = SELECTEDVALUE('vw_PRBI_Report_WeldRepairStats'[MaterialGroup]))
        ,IF(ISBLANK([Tested]) || [Tested] = 0, 0, [Tested])
    ),
    SUMX(__table,[__value])
)

 

Then use the 'table'[date] as a slicer:

vzhengdxumsft_0-1714372830942.png

The result is as follow:

vzhengdxumsft_1-1714372847572.png

Best Regards

Zhengdong Xu
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

4 REPLIES 4
v-zhengdxu-msft
Community Support
Community Support

Hi @nhuda 

How does this measure work? In my opinion, there should be some syntax errors in your formula.

Could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

 

Best Regards

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

Hi @v-zhengdxu-msft ,

 

Here're some data:

ProjectProjectStartDateMaterialGroupTestedDateTested
Project Abc8/1/2021A8/1/20210
Project Abc8/1/2021A8/1/20210
Project Abc8/1/2021A9/17/20211
Project Abc8/1/2021A9/17/20211
Project Abc8/1/2021A9/17/20211
Project Abc8/1/2021A9/17/20211
Project Abc8/1/2021A10/26/20211
Project Abc8/1/2021A10/26/20211
Project Abc8/1/2021A12/10/20211
Project Abc8/1/2021A12/10/20211
Project Abc8/1/2021A7/25/20221
Project Abc8/1/2021A7/25/20221
Project Abc8/1/2021A7/25/20221
Project Abc8/1/2021A7/25/20221
Project Abc8/1/2021A7/25/20221
Project Abc8/1/2021A7/25/20221
Project Abc8/1/2021A7/25/20221
Project Abc8/1/2021A7/28/20221
Project Abc8/1/2021A7/28/20221
Project Abc8/1/2021A7/28/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/29/20221
Project Abc8/1/2021A7/31/20221
Project Abc8/1/2021A7/31/20221
Project Abc8/1/2021A7/31/20221
Project Abc8/1/2021A7/31/20221
Project Abc8/1/2021A7/31/20221
Project Abc8/1/2021A7/31/20221
Project Abc8/1/2021A7/31/20221

 

From the above data, expected outcome is like: 

1) Period Selected - from August 1, 2021 to June 30, 2022

    Period Tested Count - 8

    Cumulative Tested Count - 8

2) Period Selected - from October 1, 2021 to June 30, 2022

    Period Tested Count - 4

    Cumulative Tested Count - 8

3) Period Selected - from January 1, 2022 to June 30, 2022

    Period Tested Count - 0

    Cumulative Tested Count - 8

 

However, I'd like to point out that - there is no issue with Scenarios 1 and 2. For Scenario 3, when Period Tested Count is 0 (no data), it doesn't return the Cumulative Tested Count as 8, it's just not returning anything (blank).

To confirm, the formula doesn't have syntax issues, it works but doesn't handle Scenario 3 above.

For pbix, how is it going to work without the data source. Is it like I export data to an excel and provide you with the excel data along with the pbix?

Please let me know.

Regards,

nhuda

Hi @nhuda 

 

Please try this:

First of all, add a new table:

 

Table = CALENDAR(MIN('vw_PRBI_Report_WeldRepairStats'[TestedDate]),MAX('vw_PRBI_Report_WeldRepairStats'[TestedDate]))

 

Then I've made some changes to your original measure:

 

Cumulative Tested = 
VAR _Select = SELECTEDVALUE(vw_PRBI_Report_WeldRepairStats[Project])
VAR _pStartDate = MINX(FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),'vw_PRBI_Report_WeldRepairStats'[Project]=_Select),[ProjectStartDate])
VAR _toDate=MAXX(ALLSELECTED('Table'),'Table'[Date])

VAR __table = 
SUMMARIZE('vw_PRBI_Report_WeldRepairStats',[MaterialGroup],"__value",
    SUMX(
        FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]>=_pStartDate && 
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]<=_toDate &&
        'vw_PRBI_Report_WeldRepairStats'[Project]=_select && 
        'vw_PRBI_Report_WeldRepairStats'[MaterialGroup] = SELECTEDVALUE('vw_PRBI_Report_WeldRepairStats'[MaterialGroup]))
        ,IF(ISBLANK([Tested]) || [Tested] = 0, 0, [Tested])
    )
)
RETURN
IF(
    HASONEVALUE(vw_PRBI_Report_WeldRepairStats[MaterialGroup]),
    SUMX(
        FILTER(ALL('vw_PRBI_Report_WeldRepairStats'),
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]>=_pStartDate && 
        'vw_PRBI_Report_WeldRepairStats'[TestedDate]<=_toDate &&
        'vw_PRBI_Report_WeldRepairStats'[Project]=_select && 
        'vw_PRBI_Report_WeldRepairStats'[MaterialGroup] = SELECTEDVALUE('vw_PRBI_Report_WeldRepairStats'[MaterialGroup]))
        ,IF(ISBLANK([Tested]) || [Tested] = 0, 0, [Tested])
    ),
    SUMX(__table,[__value])
)

 

Then use the 'table'[date] as a slicer:

vzhengdxumsft_0-1714372830942.png

The result is as follow:

vzhengdxumsft_1-1714372847572.png

Best Regards

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

Hi @v-zhengdxu-msft ,

 

Sorry for the delay in answering you, I was away for 7 days.

I just tried your formulae and it's making the Cumulative number contant irrespective of changes to both the "From" and "To" dates selected in the Date Selector. It should go higher when "To" date is changed (and there's additional data). When only "From" date is changed in the selector, it should stay the same because from the begiining of the Project to the "To" date we have the same number of Tested.

Not sure why you got the good result and mine is not good.

But I appreciate your time and effort to resolve my issue.

 

Regards,

nhuda

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.