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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Ewa_28
Helper II
Helper II

how to create measure YTD for data based on formulas

Hi,

I need to create YTD for data which was based on the following formula:

 

CombinedData =
UNION(
SELECTCOLUMNS(
'Stemple',
"Typ", "Sales",
"Sales", 'Stemple'[Sales], -- Sales value in a separate column
"Plany", BLANK(), -- Empty (blank) for the "Plany" column
"Person", 'Stemple'[Person],
"Week", 'Stemple'[Week],
"Q_numer", 'Stemple'[Q_numer],
"Region", 'Stemple'[Region],
"Year", 'Stemple'[Year]
),
SELECTCOLUMNS(
'Plany data',
"Typ", "Plany",
"Sales", BLANK(), -- Empty (blank) for the "Sales" column
"Plany", 'Plany data'[Value], -- Plany value in a separate column
"Person", 'Plany data'[Negocjator],
"Week", 'Plany data'[Week],
"Q_numer", 'Plany data'[Q_numer],
"Region", 'Plany data'[Region],
"Year", 'Plany data'[Year]
)
)

Solved: Re: data in seperating columns. How to do it? - Microsoft Fabric Community

 

I want to use slacer by week and quarter. 

Please help me.

 

Regards, Ewa

4 REPLIES 4
Anonymous
Not applicable

Hi, @Ewa_28 

Based on your information, I create sample tables:

vyohuamsft_0-1734421173058.png

vyohuamsft_1-1734421187899.png

Combine them:

CombinedData = 
UNION(
    SELECTCOLUMNS(
        'Stemple',
        "Typ", "Sales",
        "Sales", 'Stemple'[Sales],
        "Plany", BLANK(),
        "Person", 'Stemple'[Person],
        "Week", 'Stemple'[Week],
        "Q_numer", 'Stemple'[Q_numer],
        "Region", 'Stemple'[Region],
        "Year", 'Stemple'[Year]
    ),
    SELECTCOLUMNS(
        'Plany data',
        "Typ", "Plany",
        "Sales", BLANK(),
        "Plany", 'Plany data'[Value],
        "Person", 'Plany data'[Negocjator],
        "Week", 'Plany data'[Week],
        "Q_numer", 'Plany data'[Q_numer],
        "Region", 'Plany data'[Region],
        "Year", 'Plany data'[Year]
    )
)

vyohuamsft_2-1734421229414.png

 

Create a calendar table:

DateTable = 
CALENDAR(
    DATE(2023, 1, 1),
    DATE(2023, 12, 31)
)

Then create relationship, and create two measures:

SalesYTD = 
CALCULATE(
    SUM('CombinedData'[Sales]),
    DATESYTD('DateTable'[Date])
)

PlanyYTD = 
CALCULATE(
    SUM('CombinedData'[Plany]),
    DATESYTD('DateTable'[Date])
)

vyohuamsft_3-1734422027498.png

 

Here is my preview:

vyohuamsft_4-1734422060457.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

hi,  unfortunatelly, it doesn't work 😞

hi,  unfortunatelly, it doesn't work 😞
rajendraongole1
Super User
Super User

Hi @Ewa_28 - You need to create two separate YTD measures: one for Sales and one for Plany.

YTD Sales =
CALCULATE(
SUM('CombinedData'[Sales]),
FILTER(
ALL('CombinedData'),
'CombinedData'[Year] = MAX('CombinedData'[Year]) &&
'CombinedData'[Week] <= MAX('CombinedData'[Week])
)
)

 

measure 2: plany

YTD Plany =
CALCULATE(
SUM('CombinedData'[Plany]),
FILTER(
ALL('CombinedData'),
'CombinedData'[Year] = MAX('CombinedData'[Year]) &&
'CombinedData'[Week] <= MAX('CombinedData'[Week])
)
)

 

Use the Week and Q_numer columns from the CombinedData table in Slicers.
When you select a week or a quarter, the measures will automatically filter the data to show cumulative YTD values for the selected context.

Hope this works, please check

 





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

Proud to be a Super User!





Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.