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

Count step stock at specific date

Hi,

Firstly, sorry for my english.

 

We want to restitute the number of document on each status by date.

My fact table likes :

usersDate eventType event
101/03/2020Sended
104/03/2020Recevied
106/03/2020Integrated
106/03/2020Finished
201/03/2020Sended
203/03/2020Received
302/03/2020Sended
310/03/2020Received
311/03/2020Integrated
315/03/2020Finished
405/03/2020Sended
406/03/2020Received
407/03/2020Integrated

The workflow document is : Sended, received, integrated and finished

i have 3 dimensions : date, user et type event. 

 

On each date, i want to know the stock on each type event :

Type events01/03/202002/03/202003/03/202004/03/202005/03/202006/03/202007/03/202008/03/202009/03/202010/03/202011/03/202012/03/202013/03/202014/03/202015/03/2020
Sended232121111000000
Received001222111211111
Integrated000000111122221
Finish000001111111112

 

I want to create a measure but i don't know the dax syntax which can do it.

 

Thanks for your helps

 

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @gringo89 ,

 

We can use the following steps to meet your requirement.

  1. add an index column for fact table in Power Query.
 

 

  1. And we need to create relationships between tables,
 

35.png

 

  1. Then we can create a measure to get the result,
Measure =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            FILTER (
                ALLSELECTED ( 'fact table' ),
                'fact table'[Date event] <= MIN ( 'Dim Date'[Date] )
            ),
            'fact table'[users],
            "LastType",
            VAR maxIndex =
                CALCULATE (
                    MAX ( 'fact table'[Index] )
                )
            RETURN
                CALCULATE (
                    MAX ( 'fact table'[Type event] ),
                        'fact table'[Index] = maxIndex
                )
        ),
        [LastType] IN DISTINCT ( 'Dim Type event'[Type event] )
    )
) +0
 

36.png

 

BTW, pbix as attached.


Best regards,

 

 

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

Hi @v-lid-msft 

 

thanks for you're help.

I think that this approach can resolve my requirement.

 

I use SSAS (2016 version) live connection and i have an error with 'IN DISTINCT' syntax. I don't understand... 

Hummm.. the 'in' operator is not supported on sql server 2016 (compatibilty tabular 1200) 😞

Hi All,

 

Any solution for this requirement ?

 

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.