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
tatouis
New Member

Get the same results for every month of different years

Get the same results for every month of different years
what I get now is this using this measure : 

This year Paye voyageur =
CALCULATE(
    SUM('Fichier le retour'[payé voyageur]),
DATESBETWEEN('Calendar'[Date],DATE(YEAR(TODAY()),01,01),DATE(YEAR(TODAY()),12,31))
)

tatouis_0-1660752875215.png

What I wanna get is this  the yellow values be repeated for every month the same result 

tatouis_1-1660753019303.png



this is possible ? 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @tatouis 

 

This year Paye voyageur =
CALCULATE (
    SUM ( 'Fichier le retour'[payé voyageur] ),
    DATESBETWEEN (
        'Calendar'[Date],
        DATE ( YEAR ( TODAY () ), 01, 01 ),
        DATE ( YEAR ( TODAY () ), 12, 31 )
    )
)

 

 

The formula above is just another way of saying  give me the the SUM ( 'Fichier le retour'[payé voyageur] ) for 2022 and let that sum be applied to the whole calendar table thus you're getting the 2022 total for every period in your visual. If you want to ge the sum for each month in 2022  and let that be applied to all months in the calendar table, you need to write your measure differently. Here's a sample formula as well as a screenshot of the result:

Current Year Value = 
CALCULATE (
    [Sum of Values],
    FILTER ( ALL ( Dates[Year] ), Dates[Year] = YEAR ( TODAY () ) )
)

danextian_0-1660790134026.png

Please take note that I used a separate column for Year and Month and not the one from a date hierarchy.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

Hi @tatouis 

 

This year Paye voyageur =
CALCULATE (
    SUM ( 'Fichier le retour'[payé voyageur] ),
    DATESBETWEEN (
        'Calendar'[Date],
        DATE ( YEAR ( TODAY () ), 01, 01 ),
        DATE ( YEAR ( TODAY () ), 12, 31 )
    )
)

 

 

The formula above is just another way of saying  give me the the SUM ( 'Fichier le retour'[payé voyageur] ) for 2022 and let that sum be applied to the whole calendar table thus you're getting the 2022 total for every period in your visual. If you want to ge the sum for each month in 2022  and let that be applied to all months in the calendar table, you need to write your measure differently. Here's a sample formula as well as a screenshot of the result:

Current Year Value = 
CALCULATE (
    [Sum of Values],
    FILTER ( ALL ( Dates[Year] ), Dates[Year] = YEAR ( TODAY () ) )
)

danextian_0-1660790134026.png

Please take note that I used a separate column for Year and Month and not the one from a date hierarchy.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

When I used this measure works but he didn't solve the real reason why I wanna make this measure,
New dax code used:

This year Paye voyageur = CALCULATE(
    SUM('Fichier le retour'[payé voyageur]),
    FILTER(ALL('Calendar'[Año]),'Calendar'[Año]=YEAR(TODAY())) )

when I visualize it in a table it looks good but in the graph, nothing is seen if I filter by year

tatouis_2-1660812747560.png

This is what I get now : 

tatouis_1-1660812634142.png

 

what I want is to have the line of 2022 always drawn and when I filter by year the other lines are changed in this way I can always compare this year (2022)  with the year that I want to choose

tatouis_0-1660812606826.png

 

I don't know if I managed to explain myself well or not, but thank you very much for your time and your answer.

davehus
Memorable Member
Memorable Member

Hi @tatouis ,

 

My first instinct would be to check the relationships in your model. I've recreated your issue and the measure works fine for me. 

 

Did I help you today? Please accept my solution and hit the Kudos button.

i solve it thank you

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.