Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I want to preface this by pointing out that I am still a novice with Power BI, so please feel free to suggest any odd area where something could be improved.
I am struggling with understanding how to model a data set to accommodate slicers that has two different columns that need to be filtered for two different cumulative sums for reporting on stacked area plots. I have production output that can be classed as many different designs where the specific instance of a design could be production, development, or another kind of manufacturing type. The goal of the report is to be able to view a stacked area plot of all output with slicers included to allow drilling down to specific designs, specific manufacturing types, or a combination such as all A-design production or B-design development where the output is cumulatively summed over date completed to view volume out over time.
Here is a sample dummy data set. The table is sparse in that records only appear for the dates completed for the specific kinds out. Here I calculated the cumulative totals as an example. The first part I'm struggling with is how to best model this to generate a full table of results for each day for proper visualization for all output on all days.
Design | Type | Number Completed | Date Completed | Cumulative Design Outs | Cumulative Type Outs |
A | Production | 10 | 1-Jan-23 | 10 | 10 |
B | Production | 10 | 2-Jan-23 | 10 | 20 |
A | Development | 5 | 3-Jan-23 | 25 | 8 |
A | Production | 10 | 3-Jan-23 | 25 | 30 |
B | Development | 3 | 3-Jan-23 | 13 | 8 |
B | Development | 15 | 4-Jan-23 | 28 | 23 |
B | Development | 5 | 5-Jan-23 | 33 | 28 |
A | Production | 5 | 7-Jan-23 | 30 | 35 |
The following is an attempted model trying to replicate the cross-join within PBI where I hoped to get the slicers working. Please excuse the various keying columns from testing. I suspect there is a better approach than what is shown here. The 1:1 relationship back to the Facts table by the RecordKey appears to introduce undesired artifacts that I don't quite understand.
Here's the main table I setup for reporting:
Additionally, when applying the filters, the numbers don't add up despite the plot looking more like it should. Here you can see the summation by type is correct, but the the summation by design should only include the same 28 output in its tally yet it reports 33 total. This appears to be including a Production type entry that should have been filtered out as it is not in the selected data set. This isn't the only discrepancy, all of the points are off. It's as though the calculation is not taking only the selected, but instead the full data set.
Solved! Go to Solution.
I solved the problem. I just wanted to report back for future users' sake who rely on these kinds of posts as I do.
The root cause is the misunderstanding of the limits of calculated columns. The DAX expressions, despite giving the impression of a dynamic aggregation similar to measures, do not appear to support sub-group aggregation with the slicers as I thought. Measures are required to evaluate in this way.
Creating the following measure allowed implementing the dynamic sub-group aggregation with slicing as desired.
I solved the problem. I just wanted to report back for future users' sake who rely on these kinds of posts as I do.
The root cause is the misunderstanding of the limits of calculated columns. The DAX expressions, despite giving the impression of a dynamic aggregation similar to measures, do not appear to support sub-group aggregation with the slicers as I thought. Measures are required to evaluate in this way.
Creating the following measure allowed implementing the dynamic sub-group aggregation with slicing as desired.
Anyone else with input on this? I'm still searching for a solution or at least understanding if what I am trying to do is technically possible within Power BI. I would appreciate if anyone could link me to any documentation or guides on understanding the fundamentals to how the data filtering layers are intended to work as I suspect a lot of my struggle is that I can't conceptualize how the DAX filter layers and other cross-visual filters are applying to the dataset prior to aggregation.
Why is a measure preferred? I tried this, and it doesn't seem to help in any notable way. The results are essentially the same.
I tested with this calculated measure with the bare minimum for a cumulative sum (ignoring any of the requirements for the slicer).
It doesn't retain the accumulated sum for days that are missing from the original sparse data set. Instead it reports blank resulting in plots like in my first post or as above when I include the ISBLANK check to report zero instead. Basically, it is returning a cummulative sum of zero on days where there is no record in the base set rather than the result from the prior day.
When I run the same calculation in the column formula, it reports the correct cummulative sum for all days later in the calendar. The values it plots past the end in the visual are simply wrong. This appears to be because it is reporting an empty value rather than the actual result. I'm not sure why though as I'm plotting against the date in this table which exists all the way out to the end of the year. There is no apparent reason why it should be filtering the dates out of the calculation based on the sparse table. This is true even if I change from ALLSELECTED to ALL in the filter.
@sbiedrzycki , Prefer to create measure in such case
example
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))
Cumm Based on Date = CALCULATE([Net], Window(1,ABS,0,REL, ALL('date'[date]),ORDERBY('Date'[date],ASC)))
Cumm Based on Date = CALCULATE([Net], Window(1,ABS,0,REL, ALLSELECTED('date'[date]),ORDERBY('Date'[date],ASC)))
you can add filter function to filter additional data
Running Total/ Cumulative:
https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=42
Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
110 | |
105 | |
98 | |
39 | |
30 |