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
colourfullife
Post Partisan
Post Partisan

How to stop Cumulative line

Hi All

 

This is my problem below.

I have serveral cumulative lines in a graph.

how do i make my cumulative line grpah stap at the week it's meant to stop, not all the way to end.

 

I am using a userelationship to make relationship between line and week (date) table.

 

qwqwqwqw.PNG

 

Query that i used...

 

CSU SP_Contractual =
CALCULATE(
    COUNTA('Data - CSU SP PO'[CONTRACTUAL_DELIVERY_DATE]), USERELATIONSHIP('Data - CSU SP PO'[CONTRACTUAL_DELIVERY_DATE],'calendar'[Date]),
    FILTER(
        ALLSELECTED('Calendar'[Date]),
        ('Calendar'[Date] <= MAX('calendar'[Date]))))

 

 

thank you,

CL

1 ACCEPTED SOLUTION

Hi @colourfullife ,

 

Please try this:

CSU SP_IRN =
VAR __Max =
    MAXX ( ALL ( 'Sheet2' ), [Contractual] )
VAR _Min =
    MINX ( ALL ( Sheet2 ), [Contractual] )
VAR RESULT =
    IF (
        MAX ( 'Date'[Date] ) > __Max,
        BLANK (),
        CALCULATE (
            COUNTA ( 'Sheet2'[IRN] ),
            USERELATIONSHIP ( Sheet2[IRN], 'Date'[Date] ),
            FILTER (
                ALLSELECTED ( 'Date'[Date] ),
                 ( 'Date'[Date] <= MAX ( 'Date'[Date] ) )
            )
        ) + 0
    )
RETURN
    IF ( MAX ( 'Date'[Date] ) >= _Min, RESULT )

v-xuding-msft_0-1598348806438.png

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Greg_Deckler
Super User
Super User

@colourfullife - So generally you would want to wrap your calculation in an IF statement, like:

 

IF(MAX('Table'[Date]) > TODAY(),BLANK(),<your calculation goes here>)


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler  

 

is the query for stop line till today?

i want the lines stop when it supposed to stop based on the plan/ forecast date..

@colourfullife - It was an example. You really didn't post enough information for me to be more specific. I don't know what "when it is supposed to" means. Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

 

thanks for your posting. 

i attched my example pbi file and basedata excel file.

 

the lines continue till the end of year even though. it seems like it counts the blanks..

i want the lines stop where it doens't have values there..

 

PBI File : example pbi 

Data base : example database excel 

 

 

Regards,

CL

 

@colourfullife - Still no idea of exactly what you want but see if the attached PBIX (below sig) is what you are looking for. If not, going to have to explain things better. The basic pattern:

 

CSU SP_Delivery = 
VAR __Max = MAXX(ALL('Sheet2'),[Contractual])
RETURN
IF(MAX('Date'[Date]) > __Max,
    BLANK(),
    CALCULATE(
        COUNTA('Sheet2'[Delivery]), 
        USERELATIONSHIP(Sheet2[Delivery],'Date'[Date]),
        FILTER(
            ALLSELECTED('Date'[Date]),
            ('Date'[Date] <= MAX('Date'[Date]))
        )
    )
)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

 

I think you got what i want to show

Can you please find link for the graph that i created with your suggested query? using suggested query, 

because 1 line (IRN) out of 3 doesn't appear properly. i am not sure why..

 

I made what i want to show in excel : What i want to show to make it clear vision.

 

do you have any ideas?

 

Current graph 

aaaaaaaaa.PNG

 What i want to show

bbbbbbb.PNG

 

 

Hi @colourfullife ,

 

Please try this:

CSU SP_IRN =
VAR __Max =
    MAXX ( ALL ( 'Sheet2' ), [Contractual] )
VAR _Min =
    MINX ( ALL ( Sheet2 ), [Contractual] )
VAR RESULT =
    IF (
        MAX ( 'Date'[Date] ) > __Max,
        BLANK (),
        CALCULATE (
            COUNTA ( 'Sheet2'[IRN] ),
            USERELATIONSHIP ( Sheet2[IRN], 'Date'[Date] ),
            FILTER (
                ALLSELECTED ( 'Date'[Date] ),
                 ( 'Date'[Date] <= MAX ( 'Date'[Date] ) )
            )
        ) + 0
    )
RETURN
    IF ( MAX ( 'Date'[Date] ) >= _Min, RESULT )

v-xuding-msft_0-1598348806438.png

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.