Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Foton83
Frequent Visitor

Counting the number of days

Hello everybody,

I have a problem and I can't find a solution anywhere and I will ask for your help. The problem is that I have data where the movement of goods in the warehouse is shown. In one column for each day is the output of the goods and in another column is the input. I created a column that counts the balance for each day, that is, the difference for input and output. From this data, I created a measure that sums up this balance and, in the context of the commodity and date, shows the state of the commodity for the day. Unfortunately, I don't know how to create a measure that would show the number of days on which the stock of goods was zero.

 

obraz.png

 

 
 
 
 
5 REPLIES 5
Foton83
Frequent Visitor

v-shex-msft
Community Support
Community Support

HI @Foton83,

You can add a variable table use SUMMARIZE function with category field and custom field to calculate cumulative stock amount based on date and category group. Then you can use iterator function COUNTX to filter and count the row with zero stock.

Measure Totals, The Final Word 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft ,

Thank you for your help. Unfortunately I tried your solution, but I am running out of memory on my computer. I wrote this measure that creates a new table, but unfortunately it doesn't work:

 New_table = SUMMARIZE('TABLE_WITH_DATA', TABLE_WITH_DATA[Art], TABLE_WITH_DATA[date], "stock", CALCULATE(SUM(TABLE_WITH_DATA[difference], FILTER(ALL(TABLE_WITH_DATA), TABLE_WITH_DATA[date] <= MAX(TABLE_WITH_DATA[date])).

HI @Foton83,

Perhaps you can try to use the following measure formula if helps:

formula=
VAR summary =
    SUMMARIZE (
        ALLSELECTED ( 'TABLE_WITH_DATA' ),
        TABLE_WITH_DATA[Art],
        TABLE_WITH_DATA[date],
        "stock",
            CALCULATE (
                SUM ( TABLE_WITH_DATA[difference] ),
                FILTER (
                    ALLSELECTED ( TABLE_WITH_DATA ),
                    TABLE_WITH_DATA[date] <= EARLIEST ( TABLE_WITH_DATA[date] )
                )
            )
    )
RETURN
    COUNTX ( FILTER ( summary, [stock] = 0 ), [date] )

If the above expression also doesn't help, please share some dummy data paste here with table format to help us clarify your structure and test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft ,

Unfortunately, this fortmule also does not work. I can't add anything as an argument to the "Earliest" function. Power BI displays a message that "the Expression specified in the query is not a valid table expression". As you wrote I paste the table with the data:

ArtDateInQtyOutQtyDifference
3517431.10.2019196901969
3517404.11.2019016-16
3517405.11.201904-4
3517406.11.201901-1
3517407.11.2019016-16
3517408.11.2019010-10
3517412.11.2019011-11
3517413.11.2019036-36
3517414.11.2019022-22
3517415.11.201956115-59
3517418.11.201906-6
3517419.11.201905-5
3517420.11.2019012-12
3517421.11.201906-6
3517422.11.2019017-17
3517425.11.201909-9
3517426.11.2019013-13
3517427.11.201908-8
3517428.11.2019023-23
3517429.11.201905-5
3517402.12.201906-6
3517403.12.20190130-130
3517404.12.201908-8
3517405.12.2019017-17
3517406.12.2019030-30
3517409.12.201901-1
3517410.12.2019014-14
3517411.12.2019055-55
3517412.12.2019052-52
3517413.12.201907-7
3517416.12.201907-7
3517417.12.201903-3
3517418.12.2019013-13
3517419.12.201901-1
3517420.12.201914-3
3517423.12.201905-5
3517427.12.2019431
3517430.12.201901-1
3517402.01.2020237-35
3517403.01.202004-4
3517407.01.202009-9
3517408.01.20200272-272
3517409.01.202005-5
3517410.01.202004-4
3517413.01.202008-8
3517414.01.202006-6
3517415.01.202006-6
3517416.01.202009-9
3517417.01.2020090-90
3517420.01.202005-5
3517421.01.2020016-16
3517422.01.2020016-16
3517423.01.202005-5
3517424.01.202001-1
3517427.01.202001-1
3517428.01.202002-2
3517429.01.2020019-19
3517430.01.202002-2
3517431.01.2020422-18
3517403.02.202006-6
3517404.02.202004-4
3517405.02.202006-6
3517406.02.2020011-11
3517407.02.202019-8
3517410.02.202006-6
3517411.02.2020012-12
3517412.02.202006-6
3517413.02.202006-6
3517414.02.2020023-23
3517417.02.202005-5
3517418.02.202006-6
3517419.02.2020013-13
3517420.02.202008-8
3517421.02.202014-3
3517424.02.202004-4
 
 
 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.