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
VikrantC
Helper I
Helper I

Time Intelligence: Previous Month Value is Incorrect

Hi,

I have 3 month daily data for 4 players (X1, X2, X3 and Y1).  The data is arranged in 3 columns (Date, Player, Score).  All the players have data for each date (no gaps).   There is no score on weekend (no rows for weekend).  I am able to get Score for end of the month (specific date).  However, I am unable to get Data for the previous month (end of the month).  I would like to see scores for X1, X2, X3 and Y1 on 2/28, 1/31, 12/31 in one column and calculate % change from the previous month.

 

The second problem I am having is I want to Filter X1 and X2 (on date) and use variable to calculate Sum of X1, or (X1*Y1^2).  Please see the sample data in the file below.

PBI_Data (file://DESKTOP-47L4URJ/PBI_Data)PBI_Data (file://DESKTOP-47L4URJ/PBI_Data) 

I am not sure how to attach PBI file.  Pease let me know if the folder cannot be open (Dropbox).

2 ACCEPTED SOLUTIONS
v-kkf-msft
Community Support
Community Support

Hi @VikrantC ,

 

I do not have access to the link you shared, please use SharePoint Online or other tools to share your file.

Based on my understanding, I created the following example data.

 

vkkfmsft_0-1648184838583.png

 

1. Then create the measure to calculate the month end score value and compare it to the previous month end.

 

MonthEndScore = 
CALCULATE (
    SUM ( 'Table'[Score] ),
    FILTER ( 'Table', 'Table'[Date] = EOMONTH ( 'Table'[Date], 0 ) )
)
Score% = 
IF (
    [MonthEndScore] <> BLANK (),
    DIVIDE (
        [MonthEndScore],
        CALCULATE (
            [MonthEndScore],
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Date] = EOMONTH ( MAX ( 'Table'[Date] ), -1 )
                    && 'Table'[Player] = MAX ( 'Table'[Player] )
            )
        ),
        1
    ) - 1
)

vkkfmsft_1-1648185312213.png

 

2. Create the measure to calculate X1*Y1^2.

 

X1*Y1^2 = 
CALCULATE ( SUM ( 'Table'[Score] ), 'Table'[Player] = "X1" )
    * CALCULATE ( POWER ( SUM ( 'Table'[Score] ), 2 ), 'Table'[Player] = "Y1" )

vkkfmsft_2-1648185330649.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

Hi @VikrantC ,

 

Sorry for the late reply. Please try the following formula:

 

Measure = 
CALCULATE ( [Score%], 'Table'[Player] = "X1" )
    * CALCULATE ( POWER ( [Score%], 2 ), 'Table'[Player] = "Y1" )

vkkfmsft_0-1648610374458.png

 

Best Regards,
Winniz

 

 

View solution in original post

9 REPLIES 9
v-kkf-msft
Community Support
Community Support

Hi @VikrantC ,

 

I do not have access to the link you shared, please use SharePoint Online or other tools to share your file.

Based on my understanding, I created the following example data.

 

vkkfmsft_0-1648184838583.png

 

1. Then create the measure to calculate the month end score value and compare it to the previous month end.

 

MonthEndScore = 
CALCULATE (
    SUM ( 'Table'[Score] ),
    FILTER ( 'Table', 'Table'[Date] = EOMONTH ( 'Table'[Date], 0 ) )
)
Score% = 
IF (
    [MonthEndScore] <> BLANK (),
    DIVIDE (
        [MonthEndScore],
        CALCULATE (
            [MonthEndScore],
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Date] = EOMONTH ( MAX ( 'Table'[Date] ), -1 )
                    && 'Table'[Player] = MAX ( 'Table'[Player] )
            )
        ),
        1
    ) - 1
)

vkkfmsft_1-1648185312213.png

 

2. Create the measure to calculate X1*Y1^2.

 

X1*Y1^2 = 
CALCULATE ( SUM ( 'Table'[Score] ), 'Table'[Player] = "X1" )
    * CALCULATE ( POWER ( SUM ( 'Table'[Score] ), 2 ), 'Table'[Player] = "Y1" )

vkkfmsft_2-1648185330649.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

One more question to add to the earlier question.  How about I used % of change per month (instead of each date).  Would it be easier to summarize X1, Y1 in columns?

Thank you very much.  This is working.    I have one question.  Regarding X1*Y12.  How do I use the Measure Score%.  

Eventually, I was to use a Variable for (X1*Y1^2) using the Score% (% change over month for X1 and Y1).

 

Again, thank you very much.

 

Best Regards,

VC

Hi @VikrantC ,

 

Sorry for the late reply. Please try the following formula:

 

Measure = 
CALCULATE ( [Score%], 'Table'[Player] = "X1" )
    * CALCULATE ( POWER ( [Score%], 2 ), 'Table'[Player] = "Y1" )

vkkfmsft_0-1648610374458.png

 

Best Regards,
Winniz

 

 

Looks good.  I am going to try it out tonight.  Have a great day.

VikrantC
Helper I
Helper I

Hi Amit,

Your formula did not work.  I am more interested in the second problem.  Any idea?.  Thanks.

VikrantC
Helper I
Helper I

Hi Amit,

Thank you very much.  I used a similar formula.  However, I am still stuck with "The second problem I am having is I want to Filter X1 and X2 (on date) and use variable to calculate Sum of X1, or (X1*Y1^2).  Please see the sample data in the file below".    The X1 and X2 have same dates and values.

If I have two variables (X1 and X2) with dates and values (3 columns total).  How do I manipulate the formula.  For example, I want to SUM (X1^2*X2).  Basically, for each specific dates I want to calculate X1square and multiply it with X2,  Ideally, I want this to be a variable so that I can use it as part of other DAX formula.    

amitchandak
Super User
Super User

@VikrantC , Based on what I got last date of the month

 

example 

MTD Sales = CALCULATE(lastnonblankvalues('Date'[Date],SUM(Sales[Sales Amount])),DATESMTD('Date'[Date]))

Thanks Amit.  For some reason it did not work.  I did get it.  Again, thank you very much for your help.

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.