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

Want to create two column side by side.

N_Kotiyal_0-1713781544016.png

here last three weeks data and month wise data is combined ,I want to calculate change and change percentage .
last week data must be subtracted with last month of data and their percentage.
Can you help me guys with this .

1 ACCEPTED SOLUTION

Hi @N_Kotiyal ,

Please try this DAX:

CALCULATED_TABLE = 
VAR CurrentWeek = 
CALCULATE(
    MAX('Sample'[Week]),
    'Sample'[Date] = TODAY()
)
RETURN
SUMMARIZE(
    'Sample',
    'Sample'[Player Name],
    "LastMonthValue",
        CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ),
    "LastWeekValue",
        CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            'Sample'[Week] = CurrentWeek - 1 && MONTH('Sample'[Date]) = MONTH(TODAY()) && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ),
    "Change",
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            'Sample'[Week] = CurrentWeek - 1 && MONTH('Sample'[Date]) = MONTH(TODAY()) && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ) - 
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ),
    "Change %",
    DIVIDE((CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            'Sample'[Week] = CurrentWeek - 1 && MONTH('Sample'[Date]) = MONTH(TODAY()) && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ) - 
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    )), 
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    )
))

And the final output is as below:

vjunyantmsft_0-1713920560389.png


Best Regards,
Dino Tao
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

6 REPLIES 6
v-junyant-msft
Community Support
Community Support

Hi @N_Kotiyal ,

@_AAndrade Thanks for your concern about this case!

@N_Kotiyal If your dataset is just looked as this:

vjunyantmsft_0-1713850612331.png

You can use these DAXs to create two calculated columns:

Change = [21/04/2024] - [31/03/2024]
Change % = DIVIDE([Change], [31/03/2024])

And when you create visuals, put these four columns together:

vjunyantmsft_1-1713850759796.png


If your dataset doesn't look like the above, then I can give you an example.
Here is my sample data:

vjunyantmsft_3-1713851240923.png

If you want to calculated the Value last month, you can use this DAX to create a measure:

Last Month = 
VAR _today = TODAY()
VAR _lastmonth = MONTH(TODAY()) - 1
RETURN
CALCULATE(
    SUM('Sample'[Value]),
    MONTH('Sample'[Date]) = _lastmonth
)

If you want to calculated the Value last week, you can use this DAX to create a measure:

Last Week = 
VAR _Todayweek = 
CALCULATE(
    MAX('Sample'[Week]),
    'Sample'[Date] = TODAY()
)
VAR _Lastweek = _Todayweek - 1
RETURN
CALCULATE(
    SUM('Sample'[Value]),
    'Sample'[Week] = _Lastweek && YEAR('Sample'[Date]) = YEAR(TODAY()) && MONTH('Sample'[Date]) = MONTH(TODAY())
)

And then use these two measures to calculate the change:

Change = [Last Week] - [Last Month]
Change % = DIVIDE([Change], [Last Month])

Put the column Player Name and these four measures into the table visual:

vjunyantmsft_4-1713852056442.png

 

If your dataset is different from my test dataset, could you please provide me with the sample data you used, thank you!
Also, if you are looking for a way to create two columns side by side at the same time, I am sorry to say that this is not possible, Power BI Desktop can only create one column or measure at a time unless you create a calculated table.

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

@_AAndrade Can you tell me same solution using calculated table.

Hi @N_Kotiyal ,

Please try this DAX:

CALCULATED_TABLE = 
VAR CurrentWeek = 
CALCULATE(
    MAX('Sample'[Week]),
    'Sample'[Date] = TODAY()
)
RETURN
SUMMARIZE(
    'Sample',
    'Sample'[Player Name],
    "LastMonthValue",
        CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ),
    "LastWeekValue",
        CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            'Sample'[Week] = CurrentWeek - 1 && MONTH('Sample'[Date]) = MONTH(TODAY()) && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ),
    "Change",
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            'Sample'[Week] = CurrentWeek - 1 && MONTH('Sample'[Date]) = MONTH(TODAY()) && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ) - 
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ),
    "Change %",
    DIVIDE((CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            'Sample'[Week] = CurrentWeek - 1 && MONTH('Sample'[Date]) = MONTH(TODAY()) && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    ) - 
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    )), 
    CALCULATE(
        SUM('Sample'[Value]),
        FILTER(
            'Sample',
            MONTH('Sample'[Date]) = MONTH(TODAY()) - 1 && YEAR('Sample'[Date]) = YEAR(TODAY())
        )
    )
))

And the final output is as below:

vjunyantmsft_0-1713920560389.png


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

N_Kotiyal
Frequent Visitor

I think this community is useless never help me in any doubt moreover ask useless question .

N_Kotiyal
Frequent Visitor

yes

_AAndrade
Super User
Super User

Hi @N_Kotiyal,

You want to show only the columns Last Month, Last Week, change and change%? 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.