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
Anonymous
Not applicable

How to find reverse month

Hi 

I have one scenario 

shreyamukkawar_0-1672733375587.png

I want to calculate Month coloumn , condition is that higehst month should be 0 and the preceeding back month should be minus by 1.
Please help me to solve this issue.

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1672734395435.png

 

 

Month expected result CC =
VAR _currentdate = Data[Date]
VAR _maxdate =
    MAX ( Data[Date] )
VAR _mindate =
    MIN ( Data[Date] )
VAR _monthlytable =
    SUMMARIZE (
        ADDCOLUMNS (
            CALENDAR ( _mindate, _maxdate ),
            "@endofmonth", EOMONTH ( [Date], 0 )
        ),
        [@endofmonth]
    )
RETURN
    -1
        * (
            COUNTROWS ( FILTER ( _monthlytable, [@endofmonth] >= _currentdate ) ) - 1
        )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1672734395435.png

 

 

Month expected result CC =
VAR _currentdate = Data[Date]
VAR _maxdate =
    MAX ( Data[Date] )
VAR _mindate =
    MIN ( Data[Date] )
VAR _monthlytable =
    SUMMARIZE (
        ADDCOLUMNS (
            CALENDAR ( _mindate, _maxdate ),
            "@endofmonth", EOMONTH ( [Date], 0 )
        ),
        [@endofmonth]
    )
RETURN
    -1
        * (
            COUNTROWS ( FILTER ( _monthlytable, [@endofmonth] >= _currentdate ) ) - 1
        )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
tamerj1
Super User
Super User

Hi @Anonymous 
You acan use

Month =
RANKX ( 'Table', 'Table'[Date],, DESC, Dense ) - 1

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.