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
Angèle
Regular Visitor

[Power BI] Retourner le dernier mois (en cours)

Bonjour,

 

J'ai deux objets: 

- un histogramme empilé avec en axe X des mois et en axe Y des montants

- une Carte qui doit afficher le montant du mois en cours

 

Mon problème est sur ce dernier point, comme la carte affiche le montant du dernier moi en cours, lorsque je clique sur un autre mois ma carte est (vide), car pour le moment j'ai mis un filtre pour que la carte affihce uniquement le dernier mois. 

Si j'enlève mon filtre la carte affiche le total des montants de tous les mois (ce que je ne souhaite pas). 

 

Comment faire pour que :

- lorsqu'aucun mois n'est sélectionnée la carte affiche le montant du mois en cours 

- lorsqu'un mois est sélectionné ma carte affiche le montant du mois sélectionnée ?

 

Merci d'avance!

 

2 ACCEPTED SOLUTIONS
v-zhangti
Community Support
Community Support

Hi, @Angèle 

 

You can try the following methods.

Sample data:

vzhangti_0-1663917774560.png

Measure:

Measure =
IF (
    SELECTEDVALUE ( 'Table'[Date] ) = BLANK (),
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ), MONTH ( [Date] ) = MONTH ( TODAY () ) )
    ),
    SUM ( 'Table'[Value] )
)

vzhangti_1-1663917859615.pngvzhangti_2-1663917871825.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Hello ! 

 

Thank you for your answer,

 

It's more like if nothing is selected, my card should display "30" the sum of the last month, and not "70" as the picture

Angle_0-1663923129755.png

 

and if I select another month, it should display the sum of the month filteredn as the picture below

Angle_1-1663923130280.png
 

View solution in original post

6 REPLIES 6
v-zhangti
Community Support
Community Support

Hi, @Angèle 

 

You can try the following methods.

Sample data:

vzhangti_0-1663917774560.png

Measure:

Measure =
IF (
    SELECTEDVALUE ( 'Table'[Date] ) = BLANK (),
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ), MONTH ( [Date] ) = MONTH ( TODAY () ) )
    ),
    SUM ( 'Table'[Value] )
)

vzhangti_1-1663917859615.pngvzhangti_2-1663917871825.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Hello ! 

 

Thank you for your answer,

 

It's more like if nothing is selected, my card should display "30" the sum of the last month, and not "70" as the picture

Angle_0-1663923129755.png

 

and if I select another month, it should display the sum of the month filteredn as the picture below

Angle_1-1663923130280.png
 

Hi, @Angèle 

 

Measure:

Measure = 
IF (
    SELECTEDVALUE ( 'Table'[Date] ) = BLANK (),
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ), MONTH ( [Date] ) = MONTH(TODAY())-1
    )),
    SUM ( 'Table'[Value] )
)

vzhangti_0-1663925777938.pngvzhangti_1-1663925787262.png

 

Best Regards,

Community Support Team _Charlotte

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

perfect thank you so much !!

amitchandak
Super User
Super User

@Angèle , Try like

 

MTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

This Month =
var _max = eomonth(if(isfiltered('Date'),MAX( 'Date'[Date]) , today()),0)
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

Hello ! 

 

Thank you for your answer,

 

It's more like if nothing is selected, my card should display "30" the sum of the last month, and not "70" as the picture

Angle_2-1663922176643.png

 

and if I select another month, it should display the sum of the month filteredn as the picture below

Angle_3-1663922176719.png

 

 

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.

Top Solution Authors