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
Pranjal06
Frequent Visitor

Need Help with DAX!!!

Hello, I'm new to DAX and trying to get the difference between the dollar amount in each payment cycle using DAX.
I tried to search but if someone knows the same problem with solution in other post it would be helpful if you can post the link of that solution. Thank you

 

 

Pranjal06_0-1719500200828.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Greg_Deckler @ray_aramburo Thanks for your contribution on this thread.

Hi @Pranjal06 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create 'Sort Table' and 'Sort Table2'

vyiruanmsft_2-1719565135062.png

vyiruanmsft_3-1719565178079.png

2. Create measures as below

 

MIDYEAR-INITIAL = 
VAR _year =
    SELECTEDVALUE ( 'Table'[PAYMENT YEAR] )
VAR _midyear =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[PAYMENT YEAR] = _year
                && 'Table'[Type] = "DOLLAR"
                && 'Table'[PAYMENT SUBMISSION CYCLE] = "MID-YEAR"
        )
    )
VAR _initial =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[PAYMENT YEAR] = _year
                && 'Table'[Type] = "DOLLAR"
                && 'Table'[PAYMENT SUBMISSION CYCLE] = "INITIAL"
        )
    )
RETURN
    _midyear - _initial
FINAL-MIDYEAR = 
VAR _year =
    SELECTEDVALUE ( 'Table'[PAYMENT YEAR] )
VAR _final =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[PAYMENT YEAR] = _year
                && 'Table'[Type] = "DOLLAR"
                && 'Table'[PAYMENT SUBMISSION CYCLE] = "FINAL"
        )
    )
RETURN
    _final - [MIDYEAR-INITIAL]

 

3. Create a matrix with the below fields settings

vyiruanmsft_0-1719564953582.png

Toggle off the option "Text wrap" for headers and values to control the field displayToggle off the option "Text wrap" for headers and values to control the field display

Best Regards

View solution in original post

6 REPLIES 6
Pranjal06
Frequent Visitor

Hello  @Anonymous,

Thank you for the solution.

ray_aramburo
Super User
Super User

What would be the logic of the calculation? Mid-Year - Initial ?





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





I want diiference in dollar.
dollar(mid-year) - dollar(Initial)
dollar(final) - dollar(midyear)

Greg_Deckler
Community Champion
Community Champion

@Pranjal06 So what are the expected results you are trying to achieve?

Sorry, having trouble following, can you post sample data as text and expected output?
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.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I want this (Midyear-initial) field which is basically dollar(midyear)-dollar(initial) and same for Final-midyear.

PAYMENT SUBMISSION CYCLEINITIALMID-YEARFINAL 
PAYMENT YEARRAFDOLLARRAFDOLLARMIDYEAR-INITIALRAFDOLLARFINAL-MIDYEAR
20220.225 $  565,123,214.000.225 $  654,644,645.00 $    89,521,431.000.225 $  566,588,555.00 $  477,067,124.00
20230.225 $  648,946,654.000.225 $  556,564,546.00 $  (92,382,108.00)0.225 $  456,785,321.00 $  549,167,429.00
20240.225 $  321,564,542.000.225 $  456,456,655.00 $  134,892,113.000.225 $  564,789,215.00 $  429,897,102.00
Anonymous
Not applicable

@Greg_Deckler @ray_aramburo Thanks for your contribution on this thread.

Hi @Pranjal06 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create 'Sort Table' and 'Sort Table2'

vyiruanmsft_2-1719565135062.png

vyiruanmsft_3-1719565178079.png

2. Create measures as below

 

MIDYEAR-INITIAL = 
VAR _year =
    SELECTEDVALUE ( 'Table'[PAYMENT YEAR] )
VAR _midyear =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[PAYMENT YEAR] = _year
                && 'Table'[Type] = "DOLLAR"
                && 'Table'[PAYMENT SUBMISSION CYCLE] = "MID-YEAR"
        )
    )
VAR _initial =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[PAYMENT YEAR] = _year
                && 'Table'[Type] = "DOLLAR"
                && 'Table'[PAYMENT SUBMISSION CYCLE] = "INITIAL"
        )
    )
RETURN
    _midyear - _initial
FINAL-MIDYEAR = 
VAR _year =
    SELECTEDVALUE ( 'Table'[PAYMENT YEAR] )
VAR _final =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[PAYMENT YEAR] = _year
                && 'Table'[Type] = "DOLLAR"
                && 'Table'[PAYMENT SUBMISSION CYCLE] = "FINAL"
        )
    )
RETURN
    _final - [MIDYEAR-INITIAL]

 

3. Create a matrix with the below fields settings

vyiruanmsft_0-1719564953582.png

Toggle off the option "Text wrap" for headers and values to control the field displayToggle off the option "Text wrap" for headers and values to control the field display

Best Regards

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.