cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Iamnvt
Continued Contributor
Continued Contributor

first date **bleep** orders over **bleep** forecast

hi,

 

I have a table:

 

Sequence	Forecast	Orders
1	10	4
2	21	50
3	32	24
4	11	21
5	55	11

I need to find the 1st sequence that cummulative of orders > cummulative forecast. In this case, it is 2.

 

I wrote the below measure, but it is not working:

1stseq = 
var 
cumforecast = CALCULATE(SUM('Table'[Forecast]), FILTER(ALL('Table'), 'Table'[Sequence] <= MAX('Table'[Sequence])))
var
cumorder = CALCULATE(SUM('Table'[Orders]), FILTER(ALL('Table'), 'Table'[Sequence] <= MAX('Table'[Sequence])))
var
firstseq = CALCULATE(FIRSTNONBLANK('Table'[Sequence], 0), FILTER(ALL('Table'), cumorder >= cumforecast))

return
firstseq

here is the PBI file:

https://1drv.ms/u/s!Aps8poidQa5zk7FOhEXm9PiaatnpCw?e=9JVp7E

 

thanks

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Iamnvt 

Try this measure in a card visual:

1stSeq V2 =
MINX (
    'Table';
    IF (
        CALCULATE (
            SUM ( 'Table'[Orders] ) - SUM ( 'Table'[Forecast] );
            ALL ( 'Table' );
            'Table'[Sequence] <= EARLIER ( 'Table'[Sequence] )
        ) > 0;
        'Table'[Sequence]
    )
)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

View solution in original post

1 REPLY 1
AlB
Super User
Super User

Hi @Iamnvt 

Try this measure in a card visual:

1stSeq V2 =
MINX (
    'Table';
    IF (
        CALCULATE (
            SUM ( 'Table'[Orders] ) - SUM ( 'Table'[Forecast] );
            ALL ( 'Table' );
            'Table'[Sequence] <= EARLIER ( 'Table'[Sequence] )
        ) > 0;
        'Table'[Sequence]
    )
)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors