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

Showing data diff between months

Good morning Power-BI lovers! I've got a question for you all. Lets suppose i have the following example table:

Example.PNG

Right now it shows the ammount of connections for each version each different month.

I want to change it so the numbers shown will be the difference between the column month and the previous one, something like

Version     July     August     September
2.1.0          +4            +1                   -5
2.1.1         +56          +15                 -18
3.5           +102          -5                    -60

Any thoughs?     

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @markhop1 ,

 

1.  Add a conditional column.

diff.PNG

2. Create measures.

LastMonthValue =
VAR CurrentMonth =
    MAX ( 'Table'[MonthNo.] )
RETURN
    IF (
        MAX ( 'Table'[MonthNo.] )
            = CALCULATE ( MIN ( 'Table'[MonthNo.] ), ALL ( 'Table' ) ),
        0,
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Version] ),
                'Table'[MonthNo.] = CurrentMonth - 1
            )
        )
    )
Difference = FORMAT(MAX('Table'[Value])-[LastMonthValue],"+0;-0")

diff2.PNG

 

Best Regards,

Icey

 

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

4 REPLIES 4
Icey
Community Support
Community Support

Hi @markhop1 ,

 

1.  Add a conditional column.

diff.PNG

2. Create measures.

LastMonthValue =
VAR CurrentMonth =
    MAX ( 'Table'[MonthNo.] )
RETURN
    IF (
        MAX ( 'Table'[MonthNo.] )
            = CALCULATE ( MIN ( 'Table'[MonthNo.] ), ALL ( 'Table' ) ),
        0,
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Version] ),
                'Table'[MonthNo.] = CurrentMonth - 1
            )
        )
    )
Difference = FORMAT(MAX('Table'[Value])-[LastMonthValue],"+0;-0")

diff2.PNG

 

Best Regards,

Icey

 

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

markhop1
Frequent Visitor

Hey @Icey , thanks for pointing that out.

I'm actually not so good at DAX and, while I understand the idea of this function, I'm not able to make it work.
I've checked DAX documentation and it seems that CALCULATE uses ; to separate statements, maybe thats a typo in your solution?
I will post below my DAX function errrors, in case it helps you to point out what I am doing wrong

Capture.PNG
Also, I'm attaching how my table looks right now. 'Values' is the count of rows grouped by Version and Month

Capture.PNG

I will keep trying to modify it. If I find out what am I doing wrong I will post about it!

Thanks a lot, regards
Mark.

Icey
Community Support
Community Support

Hi @markhop1 ,

 

Maybe you can manually enter this formula in Power BI. Sometimes this issue will disappear after this operation.

 

Best Regards,

Icey

 

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

 

Anonymous
Not applicable

Hi Mark

If the columns of your dataset are static, then why not just create columns that calculate the difference between the months? That way you also don't overwrite existing data, which is best practise.

Let me know if this helps?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.