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
Ezzeldin
Helper I
Helper I

Total error when Retrieve the last available value from a table.

Dears,
This is a link for the Power BI file of the below-demonstrated Case:
https://www.dropbox.com/scl/fi/8d5sz6w4ksjhr6z9312dr/Use-Case.pbix?rlkey=nytwo1qj4w3tylaatarttqog6&d...

 

I have a table called "BRU_Facility_Limit" that has a value for each GL_ID in different Company_Code. as per the below screenshot.

Ezzeldin_0-1702806013035.png

 

I created a report page containing the following:
Year slicer that comes from the DATES table
Month Number slicer that comes from the DATES table

both of these slices filter a table Matrix that has in Rows a Company_Code column from the "COMPANYCODE" table & GL_ID from the "GL_Accounts" table to allow drill down from company code to its GL IDs.

Ezzeldin_1-1702806736705.png

 

I created a measure that retrieves the last available value of the GL in the "BRU_Facility_Limit" table because the values in this table are not continuous for each month. so if the user chooses Year: 2023 & Month:1 and there are no values for the GL; the measure will return the values of the last available month before the selected Year & Month. To do so I make the relationship between the DATES dimension table and the BRU_Facility_Limit table "inactive"

Ezzeldin_2-1702807482922.png

 

The problem is that the Total rows don't sum the total values of the retrieved rows in the visual, it shows the value of the last retrieved available row. the same when I drill up to the Company Code level it doesn't show the Sum of the retrieved GLs but represents the last value of the last retrieved GL.
this is the measure I used:

Sum_Facility_Limit =
VAR EndDateOfMonth = ENDOFMONTH(DATES[Date])
VAR MaxDateForAccount =
CALCULATE(
        MAX(BRU_Facility_Limit[Date]),
        BRU_Facility_Limit[Date] <= EndDateOfMonth
    )
RETURN
SUMX(
    VALUES(BRU_Facility_Limit[GL_ID]),
    CALCULATE(
        SUM(BRU_Facility_Limit[Facility_Limit]),
        BRU_Facility_Limit[Date] = MaxDateForAccount
    )
)


24 REPLIES 24
some_bih
Super User
Super User

Hi @Ezzeldin use some of "share" programs like Office 365, Dropbox, Google Drive...sharing link (hide sensitive info)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






done, please check the main post.

Hi @Ezzeldin  I wil check it and let you know.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi @Ezzeldin 

Please check your Dates table relationship, usually it should be active and after that play again with dates year and months.

some_bih_0-1703057045806.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi @some_bih ,

To clarify, the measure's output wasn't behaving as required, so I made the relationship inactive to obtain the last available value per GL. However, the issue is not with the retrieved values themselves, but rather with the totals displayed in the visual.

 

Thank you in advance for your assistance.

Hi @Ezzeldin when 

1. Table Date is set active

2. Create new measure for simple sum of Facility limit (total 4198257312) as following

Sum_simple sum =
--simple sum formula
SUM(BRU_Facility_Limit[Facility_Limit])

 

you will get total per year on Output

 

 

some_bih_0-1703061776800.png

 

Output

some_bih_1-1703061845950.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Dear @some_bih ,

the business requirements are as follows:

the business enters a limit for each GL whenever changes happen to the limit of the GL.

So the limit value for each GL does not exist for each month, and the business needs to view in the visual all the GLs in the table with the last value limit entered before the selected Month even if there is no value for the GL in the selected month.

Example:

Ezzeldin_0-1703069588281.png

 

If the user selects Year: 2023 and Month: 1

Then

the value of the GL: 9999 in the visual should be: 60,000 and the value of the GL: 8888 in the visual should be: 90,000

So the total for the company code: 1000 equals: 150,000 and the Row Total = 150,000

 

Similarly, If the user selects Year: 2022 and Month:12

Then

the value of the GL: 9999 in the visual should be: 30,000 and the value of the GL: 8888 in the visual should be: 90,000

So the total for the company code: 1000 equals: 120,000 and the Row Total = 120,000

 

That’s what I could manage, by making the relationship inactive and by the measure I did. but it is not behaving right with the totals per company code and the Total row. So I want the GL rows for Year: 2023 & Month: 1 to be the same in the screenshot and the Power BI file but the Totals I want it to be as in the below screenshot

Ezzeldin_1-1703069588281.png

 

 

Thanks in advance.

Hi @Ezzeldin 

I could not see your data example in file you provided, table BRU_facility_limit or GL account

Still, you want to see (I work in accounting and reporting :))

- 1. "balance carrying amount" / last value per GL account? 

- 2. amounts should be combined meaning if you select 2023 and February per visual it should be shown not only 2023 and Februar but other last amount?

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






is use "Enter data" option for every table in the file to allow any one with the file see the data

Ezzeldin_0-1703072385463.png

 

- 1. "balance carrying amount" / last value per GL account? 

      **Not the carrying amount only the last value available of a GL. 

- 2. amounts should be combined meaning if you select 2023 and February per visual it should be shown not only 2023 and Februar but other last amount?

         **Yes

 

Hi @Ezzeldin your data are always on end of month level or not?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi @some_bih, not a must.

Hi @Ezzeldin 

Check enclosed file. I created two measures as below.

I check for two GL ID's as shown on picture below

Sum_simple sum =
--simple sum formula
SUM(BRU_Facility_Limit[Facility_Limit])
 
Sum adjusted =
IF (
    ISEMPTY ( BRU_Facility_Limit ),
    CALCULATE ( [Sum_simple sum], OFFSET ( -1,, ORDERBY ( 'DATES'[Date] ), ) ),
    [Sum_simple sum]
)

 

some_bih_0-1703163676388.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






if gives me an error.

Ezzeldin_0-1703492126702.png

 

@Ezzeldin this is known bug. Dont worry, check results





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Unfortunately, the result is still incorrect.

Hi @Ezzeldin give me example of wrong and one example of correct /expected output based on enclosed file





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






hi @some_bih ,

Based on the screenshot provided, I tested GL 102122. When I selected Year 2023 and Month 1 for Company Code 1000, the expected result was 200,000,000. Similarly, for Company Code 2000, the expected result was 300,000,000. The total amount was expected to be 500,000,000.

 

Ezzeldin_1-1703583308420.png

 

 

Hi @Ezzeldin 

I filtered out only GL 102122 below how to get 200 000 for January 2023. Mark rows

some_bih_0-1703591747917.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






200,000,000 is the last available value for GL: 102122 in company code: 1000 when we choose Year: 2023 and Month: 1.
if we choose Year: 2022 and Month: 2 the last available value for GL: 102122 in company code: 1000 is:165,000,000

same for company code: 2000 when we choose Year: 2023 and Month: 1 the result for GL: 102122 should be: 300,000,000 which is the last available value before the last date of the selected month as my measure dose.
the problem with my measure is with the totals.

Hi @Ezzeldin I will take a look and provide answer.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






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.