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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Nafeesa
Frequent Visitor

Rough countback for GRNI value vs goods booked in

I want to know roughly how many days of goods receipts the current GRNI balance is made up of;

 

In the attached example, the GRNI balance was £406k on the 7th of September.

 

Doing a reverse cumulative total of the total goods booked in from today backwards shows that the balance is made up of roughly 26 days of receipts.

 

I want to have a variable comparing the current GRNI total balance to the reverse cumulative total and return the date it exceeds the balance. I then want to return the number of days from that date until todays to give a rough countback calculation.

 

What is the best way to approach this?

 

Capture.JPG

Thanks,

 

Nafeesa.

 

 

 

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Nafeesa,

 

Try this measure:

 

Days of goods receipts = 
VAR vMaxDate =
    CALCULATE ( MAX ( Goods[Posting Date] ), ALLSELECTED () )
VAR vGRNI = [GRNI]
VAR vTableReverseTotal =
    ADDCOLUMNS (
        VALUES ( Goods[Posting Date] ),
        "@ReverseTotal", [Reverse Cumulative Total of goods booked in]
    )
VAR vTableFlag =
    ADDCOLUMNS ( vTableReverseTotal, "@Flag", IF ( [@ReverseTotal] > vGRNI, 1 ) )
VAR vTableFlagFilter =
    FILTER ( vTableFlag, [@Flag] = 1 )
VAR vDateExceeded =
    MAXX ( vTableFlagFilter, Goods[Posting Date] )
VAR vResult =
    DATEDIFF ( vDateExceeded, vMaxDate, DAY )
RETURN
    vResult

 

DataInsights_0-1662818863728.png

 





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

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@Nafeesa,

 

Try this measure:

 

Days of goods receipts = 
VAR vMaxDate =
    CALCULATE ( MAX ( Goods[Posting Date] ), ALLSELECTED () )
VAR vGRNI = [GRNI]
VAR vTableReverseTotal =
    ADDCOLUMNS (
        VALUES ( Goods[Posting Date] ),
        "@ReverseTotal", [Reverse Cumulative Total of goods booked in]
    )
VAR vTableFlag =
    ADDCOLUMNS ( vTableReverseTotal, "@Flag", IF ( [@ReverseTotal] > vGRNI, 1 ) )
VAR vTableFlagFilter =
    FILTER ( vTableFlag, [@Flag] = 1 )
VAR vDateExceeded =
    MAXX ( vTableFlagFilter, Goods[Posting Date] )
VAR vResult =
    DATEDIFF ( vDateExceeded, vMaxDate, DAY )
RETURN
    vResult

 

DataInsights_0-1662818863728.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.