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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Marshmallow
Helper II
Helper II

Help to create double line chart for YOY comparison with conditions from multiple columns

Hi,

 

Can someone please help me with the DAX as I can't seem to get it right? I need to create a stacked line charts for YOY to show total rows of PA_Date that is not BLANK (01/01/00) per Month in the Financial Year (starting from July) and column 'RejectionDate is BLANK (01/01/00). Hopefully this makes sense.

 

Below is my sample data:

RejectionDatePA_Date
01/01/0001/01/00
01/01/0001/01/00
01/01/0001/01/00
01/01/0001/01/00
16/12/2401/01/00
01/01/0001/01/00
01/01/0014/08/24
01/01/0013/08/23
01/01/0030/09/24
01/01/0003/06/24
01/01/0017/08/23
29/01/2402/07/23
01/01/0012/04/24
01/01/0003/09/24
01/01/0022/12/22
01/01/0012/04/24
01/04/2501/04/25
01/01/0006/12/24
09/05/2509/05/25
19/02/2518/02/25
28/05/2401/01/00
14/01/2504/09/24
27/02/2527/02/25
21/05/2530/09/24
01/01/0002/07/24
01/01/0010/09/23
01/01/0030/07/24
01/01/0011/11/24
30/01/2401/11/22
01/01/0022/07/25
09/06/2509/06/25
01/05/2409/11/23
13/06/2513/06/25
01/01/0010/07/25
01/01/0012/06/25
06/08/2401/05/24
01/01/0020/08/24
01/01/0017/06/25
01/01/0023/08/24
08/04/2405/08/21
01/01/0014/05/24
01/01/0008/06/22
01/01/0026/11/24
01/01/0005/12/24
14/02/2429/08/22
01/01/0029/07/24
01/01/0018/06/25
01/01/0002/07/24
01/01/0018/06/25
01/01/0001/01/00
01/01/0028/02/25
01/01/0004/07/23
26/02/2501/01/00
25/06/2524/06/25
01/01/0001/04/25
11/09/2404/09/24
01/01/0031/07/23
01/01/0020/09/24
01/01/0025/06/24
01/01/0002/07/23
01/01/0031/03/25
01/01/0030/09/24
01/01/0014/10/24
01/01/0018/02/25
01/01/0011/07/24
01/01/0005/12/24
01/01/0008/11/24
01/01/0006/11/24
01/01/0019/09/24
01/01/0004/11/24
01/01/0001/01/00
01/01/0015/07/25
01/01/0006/02/25
01/01/0004/09/25
01/01/0003/06/25
01/01/0011/07/25
26/05/2530/09/24
01/07/2518/02/25
01/01/0030/09/24
01/01/0024/09/24
14/11/2416/05/24
01/01/0026/05/25
01/01/0009/09/25
01/01/0030/09/24
01/01/0008/07/25
01/01/0001/01/00
25/03/2524/03/25
01/01/0028/02/25
01/01/0025/08/25

 

I need to be able to create a stacked line chart like the sample below - with no luck. (ps: ignore the vertical line)

Marshmallow_0-1757951660180.png

 

 

What I have done so far:

1. I created a calendar table

Calendar_New =
VAR _calendar =
    ADDCOLUMNS (
        CALENDAR (
            DATE ( YEAR ( MIN (data ) ), 1, 1 ),
            DATE ( YEAR ( MAX ( data ) ), 12, 31 )
        ),
        "Calendar Year", YEAR ( [Date] ),
        "Month name", FORMAT ( [Date], "mmmm" ),
        "Month number", MONTH ( [Date] )
    )
RETURN
    ADDCOLUMNS (
        _calendar,
        "Financial Year",
            IF (
                [Month number] >= 7,
                "FY" & FORMAT ( [Date], "yy" ) & "-"
                    & FORMAT ( [Date], "yy" ) + 1,
                "FY"
                    & FORMAT ( [Date], "yy" ) - 1 & "-"
                    & FORMAT ( [Date], "yy" )
            ),
        "Financial Year sort",
            IF ( [Month number] >= 7, [Calendar Year] + 1, [Calendar Year]),
        "Financial Month number",
            IF ( [Month number] >= 7, [Month number] - 2, [Month number] + 12 - 2 ),
        "Month name index",
            IF ([Month number] >= 7, [Month number]-6, [Month number] +6)
    )
 
2. Do total count which i think there is an issue here
Count_PA =
CALCULATE(
    COUNTROWS(data),
    Not(ISBLANK(data[RejectionDate])))
 
After this step my other calculations have returned incorrect numbers -- step 3 and 4 below -- 😞
 
3. 
Current Yr ProvAppr =
var _currentyear =
    year(CALCULATE(
        max(data[PA_Date]),
         Not ISBLANK(data[RejectionDate]), REMOVEFILTERS() ))

var _currentFY=
    MAXX(
        filter(All(Calendar_New), 'Calendar_New'[Calendar Year] = _currentyear),
        'Calendar_New'[Financial Year])

var _count =
    CALCULATE(
        [Count_ProvAppr],
        'Calendar_New'[Financial Year] = _currentFY)

        RETURN
        _count
 
4. 
Previous Yr ProvAppr=
var _currentyear = year(CALCULATE(max(data[PA_Date]), Not ISBLANK(data[RejectionDate]) REMOVEFILTERS() ) )

var _currentFYsort =
    MAXX(
        Filter(ALL('Calendar_New'), 'Calendar_New'[Calendar Year] = _currentyear),
        'Calendar_New'[Financial Year sort])

var _count =
    CALCULATE([Count_ProvAppr],
     'Calendar_New'[Financial Year sort] =  _currentFYsort-1)

RETURN
    if([Current Yr ProvAppr], _count)
 
 
These are the steps I did and I can't get my total numbers right :(. 
 
Pls help. 
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Marshmallow ,

 

Based on your description I believe that your main problem is the measure:

Count_PA =
CALCULATE(
    COUNTROWS(data),
    Not(ISBLANK(data[RejectionDate])))

 

This calculation gets the values of the Data were the Rejection date is not blank you refer that you want to have the ones where the rejection date is blank so try the following code:

Count_PA = 
    COUNTROWS(FILTER(data,
    data[RejectionDate] = BLANK()))

 

Then setup your chart with the following:

  • X-Axis - Month Name
  • Y-Axis - Count_PA
  • Legend: Finacial Year

Result below:

MFelix_0-1757955598594.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @Marshmallow ,

 

Based on your description I believe that your main problem is the measure:

Count_PA =
CALCULATE(
    COUNTROWS(data),
    Not(ISBLANK(data[RejectionDate])))

 

This calculation gets the values of the Data were the Rejection date is not blank you refer that you want to have the ones where the rejection date is blank so try the following code:

Count_PA = 
    COUNTROWS(FILTER(data,
    data[RejectionDate] = BLANK()))

 

Then setup your chart with the following:

  • X-Axis - Month Name
  • Y-Axis - Count_PA
  • Legend: Finacial Year

Result below:

MFelix_0-1757955598594.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.