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

Creating a Card for displaying the previous months count

Hello,

 

I need to create two cards and a month slicer in my dashboard.  One card needs to coordinate with the month slicer and show me the current count of calls in that month.  The other card needs to display the count from the previous month. 

2017-10-04_7-39-27.png2017-10-04_7-27-26.png

 

I have attempted to use the PREVIOUSMONTH funtion but because my open at column contains dates with the same time the function will not work.  I also tried pointing the function to my month table key but that also does not provide me with the results I am looking for.  

 

Any help would be greatly appreciated. 

 

thansk,  

 

Also, I would also like to get some formating for the previous month card to show if it was lower or higher but that is less important.  

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @adamsumm,

 

The column opened_at contains time parts that isn't necessary in this scenario. The most important point is the time part is bad for the relationship.

1. Create a new column:

Relationship = [Opened_at].[Date]

2. Establish relationship between this table and the date table.

3. Two measures.

 

CurrentMonthAmount = count(Table1[Number])
PreviousMonthAmount =
VAR currentAmount =
    COUNT ( Table1[Opened_at] )
VAR previousAmount =
    CALCULATE ( COUNT ( 'Table1'[Opened_at] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )
RETURN
    IF (
        previousAmount < currentAmount,
        CONCATENATE ( previousAmount, UNICHAR ( 9660 ) ),
        IF (
            previousAmount > currentAmount,
            CONCATENATE ( previousAmount, UNICHAR ( 9650 ) ),
            previousAmount
        )
    )

Creating a Card for displaying the previous months count.jpg

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

Community Support Team _ Dale
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
v-jiascu-msft
Employee
Employee

Hi @adamsumm,

 

The column opened_at contains time parts that isn't necessary in this scenario. The most important point is the time part is bad for the relationship.

1. Create a new column:

Relationship = [Opened_at].[Date]

2. Establish relationship between this table and the date table.

3. Two measures.

 

CurrentMonthAmount = count(Table1[Number])
PreviousMonthAmount =
VAR currentAmount =
    COUNT ( Table1[Opened_at] )
VAR previousAmount =
    CALCULATE ( COUNT ( 'Table1'[Opened_at] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )
RETURN
    IF (
        previousAmount < currentAmount,
        CONCATENATE ( previousAmount, UNICHAR ( 9660 ) ),
        IF (
            previousAmount > currentAmount,
            CONCATENATE ( previousAmount, UNICHAR ( 9650 ) ),
            previousAmount
        )
    )

Creating a Card for displaying the previous months count.jpg

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

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

Thank you @v-jiascu-msft  for the solution, is there anyway from this code, I can set the color red (negative), grey (blank or 0) and green (positive) for both # of differences and the unichar arrows? (see the screenshot below) 

quyenduong_0-1676891825254.png

 

Thank you.
@amitchandak are there any chance you might know this?

This seems to work!   Thank you so much!  

 

Follow up question though.  Is there a way to do the same thing but with a percentage of the total instead of a count?  

 

thanks,  

Hi @adamsumm,

 

Did you work it out? Maybe you can try it like this.

% =
VAR total =
    CALCULATE ( COUNT ( 'Table1'[Opened_at] ), ALL ( 'Calendar' ) )
VAR currentAmount =
    COUNT ( Table1[Opened_at] )
VAR previousAmount =
    CALCULATE ( COUNT ( 'Table1'[Opened_at] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )
RETURN
    IF (
        previousAmount < currentAmount,
        CONCATENATE ( previousAmount / total, UNICHAR ( 9660 ) ),
        IF (
            previousAmount > currentAmount,
            CONCATENATE ( previousAmount / total, UNICHAR ( 9650 ) ),
            previousAmount
        )
    )

Or,

 

% 2 =
VAR total =
    CALCULATE ( COUNT ( 'Table1'[Opened_at] ), ALL ( 'Calendar' ) )
VAR currentAmount =
    COUNT ( Table1[Opened_at] )
VAR previousAmount =
    CALCULATE ( COUNT ( 'Table1'[Opened_at] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )
RETURN
    IF (
        previousAmount < currentAmount,
        CONCATENATE (
            CONCATENATE ( previousAmount / total * 100, "%" ),
            UNICHAR ( 9660 )
        ),
        IF (
            previousAmount > currentAmount,
            CONCATENATE (
                CONCATENATE ( previousAmount / total * 100, "%" ),
                UNICHAR ( 9650 )
            ),
            previousAmount
        )
    )

Creating a Card for displaying the previous months count.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

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

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.