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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tomek1982
Helper I
Helper I

subtotal for last day from period

I have 2 issues I need a support from the community.

 

I would like to calculate sum of "Wartość jednostek" for last day of the selected period. During troubleschooting I created "measure" and "measure 2" but none of those is really working as intended.
update: displaying summary for the last day is solved by puting that into separate card with top 1 flitering by latest date. Unfortunatelly calculation is still wrong and missing calculation for a middle date.

 

Tomek1982_0-1667055694579.png

 

 

Second issue is that none of those sumarize values from date in the middle. It seems that the issue may be linked to the way both tables are connected. Inside the table 2 there is no data for 2022-10-11. For this day previous values are taken.

 

PBIX attached here

 

1 ACCEPTED SOLUTION

The solution was to pivot both tables and use the following formula to fill missing values:

 

ilość a = LOOKUPVALUE('Table1'[qty a], Table1[Date], CALCULATE(LASTNONBLANK(Table1[Date], 1),FILTER(Table1, Table1[qty a]>0 && EARLIER(Table1[Date])>=Table1[Date])))

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

Measure 2 = 
var last_date = LASTDATE('Table1'[Date])
return SUMX (FILTER('Table1','Table1'[Date] = last_date), [Wartość jednostek] )

 

There is no need to check for HASONEVALUE - the SUMX formula also work for single items.

@lbendlin It is not really working:

Tomek1982_0-1667157649362.png

 

values for 11.10 are not calculated, values for 12.10 are calculated wrongly

 

DateColumn1Max of wycenaRunning ilosc jednostekWartość jednostekMeasure 2expected valuedaily subtotallast date
2022-10-10 00:00a127,6861,967911,057911,057911,05 2022-10-10 00:00
2022-10-10 00:00b592,6124,0514252,2714252,2714252,27 2022-10-10 00:00
2022-10-10 00:00c123,5990,0211125,5711125,5711125,5733288,902022-10-10 00:00
2022-10-11 00:00a127,5561,967903,00 7903,00 2022-10-11 00:00
2022-10-11 00:00b591,0524,0514214,75 14214,75 2022-10-11 00:00
2022-10-11 00:00c125,8890,0211331,72 11331,7233449,472022-10-11 00:00
2022-10-12 00:00a126,1594,0411863,154046,8911863,15 2022-10-12 00:00
2022-10-12 00:00b593,5548,128549,7514274,8828549,76 2022-10-12 00:00
2022-10-12 00:00c121,08188,2522793,3111893,6922793,3163206,212022-10-12 00:00

it is not clear (to me) how you want to group this.  Is it last date by Column1, or last date overall?

Maybe the table was misleading little bit. I do not want to display "daily subtotal" in a table.

What I would like to achieve is something like this:

Tomek1982_0-1667397622639.png

where measure 2 is a sum of "wartosc jednostek". The problem is that:

- for 2022-10-10 it is working fine

- for 2022-10-11 it is not working at all

Tomek1982_2-1667397863058.png

- for 2022-10-12 calculation is wrong

Tomek1982_3-1667397917864.png

PBIX attached here

The solution was to pivot both tables and use the following formula to fill missing values:

 

ilość a = LOOKUPVALUE('Table1'[qty a], Table1[Date], CALCULATE(LASTNONBLANK(Table1[Date], 1),FILTER(Table1, Table1[qty a]>0 && EARLIER(Table1[Date])>=Table1[Date])))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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