The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I have a data set that get new versions daily, this data set has four columns: version, date, basket and apples. Basically this tells us how many apples are, or will be, in a basket every single day, but whenever we get a new version we lose the data from the previous day version.
This is how the data would look when looking at the version from the 3th
Date | data with no formula |
1st | |
2nd | |
3th | 1 |
4th | 3 |
5th | 6 |
this is how it would look when looking at a version from the 4th (future numbers can change as they update)
Date | data with no formula |
1st | |
2nd | |
3th | |
4th | 3 |
5th | 7 |
Using this formula I was able to fill the blanks we have for previous dates on newer versions using data from previous versions. FYI: Versions are copied to another table to be used as reference.
SUMMARY_APPLES =
IF(
ISBLANK( MAX( SUMMARY_APPLES[# OF APPLES] ) ),
CALCULATE(
LASTNONBLANK( SUMMARY_APPLES[# OF APPLES], SUMMARY_APPLES[# OF APPLES]),
FILTER(
ALL( SUMMARY_VERSIONS ),
SUMMARY_VERSIONS[VERSION #] < MAX( SUMMARY_VERSIONS[VERSION #])
)
),
MAX( SUMMARY_APPLES[# OF APPLES] )
)
This is a comparison of how the data looks before and after the formula (when looking at a version from the 4th):
Date | data with no formula | data with formula |
1st | 2 | |
2nd | 3 | |
3th | 1 | |
4th | 3 | 3 |
5th | 7 | 7 |
Total | 10 | 10 |
As seen in the Total row, my problem arises when I try to get the total, as it only sums the originally non blank values. I know this happens because LASTNONBLANK does not work on an aggregation level, only on a row basis level, but is there any way to obtain the total sum INCLUDING all the values? (IE: total being 16 instead of 10)
Hi, @armonz
Please provide more details with your desired output and pbix file without privacy information (or some sample data)
Best Regards
Yongkang Hua
Thank you for the reply, @Anonymous.
I can't provide sample data due to privacy issues, but hopefully this explains it:
Below it's a rough example of how the data is recevied
version | date | basket | apples |
2024/12/03 | 2024/12/03 | basket 1 | 3 |
2024/12/03 | 2024/12/04 | basket 1 | 1 |
2024/12/03 | 2024/12/05 | basket 1 | 6 |
... | ... | ... | ... |
2024/12/03 | 2024/12/31 | basket 1 | 5 |
2024/12/04 | 2024/12/04 | basket 1 | 1 |
2024/12/04 | 2024/12/05 | basket 1 | 6 |
2024/12/04 | 2024/12/06 | basket 1 | 8 |
... | ... | ... | ... |
2024/12/04 | 2024/12/31 | basket 1 | 5 |
You can ignore the basket columns, that is basically used as a slicer for different baskets. The important part is as you can see every version has data for the entire month, we get a new version every day, but every new version starts with the day on which it was sent and has no data for past dates.
This means that if I want to see the data for the entire month of December, using the latest version I would be showing a table like this:
Date | data with no formula |
1st | |
2nd | |
3th | |
4th | 3 |
5th | 7 |
Using the before mentioned formula I am able to fill the blanks with the data from previous versions, like so:
Date | data with no formula | data with formula |
1st | 2 | |
2nd | 3 | |
3th | 1 | |
4th | 3 | 3 |
5th | 7 | 7 |
Total | 10 | 10 |
I have a separate view where I want to show the total sum for the entire month, no matter the version I'm looking at, but at this point the formula only aggregates the numbers available in each version, ignoring the values that were filled with data from previous versions. In the table above the total shows as 10, when I need to show 17.
I hope this explains how the data works and my issue. Thanks, again.
User | Count |
---|---|
68 | |
63 | |
59 | |
54 | |
28 |
User | Count |
---|---|
183 | |
80 | |
62 | |
46 | |
38 |