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

Trouble with calculation(help)

Hello everyone. In the screenshot one, I show my test pattern. The task is to calculate the values ​​according to the formula below:
The SUM"Count_of_sales" + Sum "Count of Calls" -100.

It is necessary to consider this formula both for all managers, and for one specific one. It is necessary to read the formula both for a day and for several days. The problem is the static number "100". I can’t understand how to increase it depending on the number of days.

There is also one more problem that 1 manager can fill out a report twice a day, and if the number "100" is done with a regular column, the data will be distorted. This is shown in screenshot two.
I tried to make sure that the constant "100" was added to the manager only 1 time per day, but it did not work out for me.

If you have any ideas how to do this, I will be very grateful.

Link on my project: https://www.dropbox.com/s/e0z633ns9q8wzq3/IA.pbix?dl=0
1.png

 

2.png

 

1 ACCEPTED SOLUTION

Hi,

 

Please try this:

constant = 
IF (
    'Table'[Index]
        = CALCULATE (
            MIN ( 'Table'[Index] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Date] = EARLIER ( 'Table'[Date] )
                    && 'Table'[Manager] = EARLIER ( 'Table'[Manager] )
            )
        ),
    100 + DATEDIFF ( MIN ( 'Table'[Date] ), 'Table'[Date], DAY ),
    0
)

The result shows:

22.PNG

 

Best Regards,

Giotto

View solution in original post

6 REPLIES 6
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please take following steps:

1)Try to add an index column.

2)Try this column:

constant = 
IF (
    'Table'[Index]
        = CALCULATE (
            MIN ( 'Table'[Index] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = EARLIER ( 'Table'[Date] ) )
        ),
    100 + DATEDIFF ( MIN ( 'Table'[Date] ), 'Table'[Date], DAY ),
    0
)

3)The result shows:

20.PNG

Here is the test pbix file:

pbix 

Hope this is what you want.

 

Best Regards,

Giotto

 

How can I make the automatic completion of the "index" in increments of +1. If not difficult, please answer

Hi,

 

If your data was imported from Query Editor not by calculated table, you can easily add an index column in Query Editor.

If you enter data manually by calculated table, i think you can add index column only by hand in this case due to lack of distinct key column.

 

Best Regards,

Giotto

TY so match.😀

This will not solve my problem. This formula that you wrote adds the value 100, only to manager1, and I need to add a number to all unique managers (manager1, manager2, manager3). I also pointed out that managers can fill out a daily report several times. I need 1 manager to be assigned a constant only 1 time per day. This is difficult, and therefore turned to the forum.

Hi,

 

Please try this:

constant = 
IF (
    'Table'[Index]
        = CALCULATE (
            MIN ( 'Table'[Index] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Date] = EARLIER ( 'Table'[Date] )
                    && 'Table'[Manager] = EARLIER ( 'Table'[Manager] )
            )
        ),
    100 + DATEDIFF ( MIN ( 'Table'[Date] ), 'Table'[Date], DAY ),
    0
)

The result shows:

22.PNG

 

Best Regards,

Giotto

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.