Forum Discussion

Louay's avatar
Louay
New Member
2 years ago
Solved

Cumul des actions

Cumul act =
VAR SelectedOrigine = SELECTEDVALUE('Cumul Actions'[Origine première])
VAR SelectedProcessus = SELECTEDVALUE('Cumul Actions'[Processus])

RETURN
IF (
    ISFILTERED('Cumul Actions'[Origine première]) && ISFILTERED('Cumul Actions'[Processus]) ,
    CALCULATE (
        COUNT('Cumul Actions'[Processus]),
        FILTER (
            ALL('Cumul Actions'),
            'Cumul Actions'[Date] <= MAX('Cumul Actions'[Date])
                && 'Cumul Actions'[Origine première] = SelectedOrigine
                && 'Cumul Actions'[Processus] = SelectedProcessus
        )
    ),
    CALCULATE (
        COUNT('Cumul Actions'[Processus]),
        FILTER (
            ALL('Cumul Actions'),
            'Cumul Actions'[Date] <= MAX('Cumul Actions'[Date])
        )
    )
)
 
Bonjour, J'ai utiliser ce code pour calculer le cumul des action au cours du temps tout en prendre en consideration des filtres processus et origine premiere selectionné(s). Sans selectionné auccun filtre ça marche correctement et calculer le cumul générale mais lors de selection d'un ou plusieurs filtres il affiche seulement les mois concernés par ce filtre mais avec les valeurs generales.

 

 

  • I find the solution 

    Cumuls des actions =
    VAR SelectedOrigine = SELECTEDVALUE('Actions'[Origine première])
    VAR SelectedProcessus = SELECTEDVALUE('Actions'[Processus])

    RETURN
    IF (
        ISFILTERED('Actions'[Origine première]) && ISFILTERED('Actions'[Processus]),
        CALCULATE (
            COUNT('Actions'[Processus]),
            FILTER (
                ALLSELECTED('Actions'),
                'Actions'[Année/Mois] <= MAX('Actions'[Année/Mois])
                    && 'Actions'[Origine première] = SelectedOrigine
                    && 'Actions'[Processus] = SelectedProcessus
            )
        ),
        CALCULATE (
            COUNT('Actions'[Processus]),
            FILTER (
                ALLSELECTED('Actions'),
                'Actions'[Année/Mois] <= MAX('Actions'[Année/Mois])
            )
        )
    )

2 Replies

  • Louay , In such case, it is better to have a separate date table, joined with the date of your table. And use fields of date table in measure, visual, and slicers

     

    Then you can use measures like

     

    Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

    Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))

    Cumm Based on Date = CALCULATE([Net], Window(1,ABS,0,REL, ALL('date'[date]),ORDERBY('Date'[date],ASC)))

    Cumm Based on Date = CALCULATE([Net], Window(1,ABS,0,REL, ALLSELECTED('date'[date]),ORDERBY('Date'[date],ASC)))

     

     

    Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
    https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

     

  • I find the solution 

    Cumuls des actions =
    VAR SelectedOrigine = SELECTEDVALUE('Actions'[Origine première])
    VAR SelectedProcessus = SELECTEDVALUE('Actions'[Processus])

    RETURN
    IF (
        ISFILTERED('Actions'[Origine première]) && ISFILTERED('Actions'[Processus]),
        CALCULATE (
            COUNT('Actions'[Processus]),
            FILTER (
                ALLSELECTED('Actions'),
                'Actions'[Année/Mois] <= MAX('Actions'[Année/Mois])
                    && 'Actions'[Origine première] = SelectedOrigine
                    && 'Actions'[Processus] = SelectedProcessus
            )
        ),
        CALCULATE (
            COUNT('Actions'[Processus]),
            FILTER (
                ALLSELECTED('Actions'),
                'Actions'[Année/Mois] <= MAX('Actions'[Année/Mois])
            )
        )
    )