Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
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:
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
Solved! Go to 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:
The result is as follow:
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 @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:
Project | ProjectStartDate | MaterialGroup | TestedDate | Tested |
Project Abc | 8/1/2021 | A | 8/1/2021 | 0 |
Project Abc | 8/1/2021 | A | 8/1/2021 | 0 |
Project Abc | 8/1/2021 | A | 9/17/2021 | 1 |
Project Abc | 8/1/2021 | A | 9/17/2021 | 1 |
Project Abc | 8/1/2021 | A | 9/17/2021 | 1 |
Project Abc | 8/1/2021 | A | 9/17/2021 | 1 |
Project Abc | 8/1/2021 | A | 10/26/2021 | 1 |
Project Abc | 8/1/2021 | A | 10/26/2021 | 1 |
Project Abc | 8/1/2021 | A | 12/10/2021 | 1 |
Project Abc | 8/1/2021 | A | 12/10/2021 | 1 |
Project Abc | 8/1/2021 | A | 7/25/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/25/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/25/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/25/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/25/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/25/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/25/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/28/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/28/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/28/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/29/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/31/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/31/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/31/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/31/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/31/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/31/2022 | 1 |
Project Abc | 8/1/2021 | A | 7/31/2022 | 1 |
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:
The result is as follow:
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
User | Count |
---|---|
90 | |
73 | |
68 | |
63 | |
56 |
User | Count |
---|---|
103 | |
94 | |
74 | |
60 | |
59 |