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
Anonymous
Not applicable

Data difference between two dates

Hello, I am a total newbie into PoweBi and I need to get the difference between two months of fruit eaten, to see how much more or less fruit did I eat this month comapred to the last one. Since my english is poor, let me show you, what I mean on example:

 this is how the data looks like:

datefruiteaten
3-22Apples5
3-22Oranges2
4-22Apples4
4-22Oranges3


this is what I need:

fruiteaten 3-22eaten 4-22difference
Apples52-3
Oranges43-1

the calculation should be: [eaten 4-22]-[eaten 3-22]=difference

 

How can I make this in powerBi? Is it possible to change column values by filter? Like if I wanted to change 3-22 to 1-22 or any other month? If I could chose the month values in slicer, that would be awesome. 

Thanks to anyone willing ot help. 🙂 

3 REPLIES 3
Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create measure.

eaten 3-22 =
IF(
    MAX('Table'[fruit])="Apples",
CALCULATE(SUM('Table'[eaten]),FILTER(ALL('Table'),'Table'[date]=DATE(2022,3,22)&&'Table'[fruit]="Apples")),
CALCULATE(SUM('Table'[eaten]),FILTER(ALL('Table'),'Table'[date]=DATE(2022,4,22)&&'Table'[fruit]="Apples")))
eaten 4-22 =
IF(
    MAX('Table'[fruit])="Apples",
CALCULATE(SUM('Table'[eaten]),FILTER(ALL('Table'),'Table'[date]=DATE(2022,3,22)&&'Table'[fruit]="Oranges")),
CALCULATE(SUM('Table'[eaten]),FILTER(ALL('Table'),'Table'[date]=DATE(2022,4,22)&&'Table'[fruit]="Oranges")))
difference = [eaten 4-22] - [eaten 3-22]

2. Result:

vyangliumsft_0-1649130634144.png

Please click here for the pbix file

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Is there a solution without using the name of fruit? Let's say I have hunderts of different fruit names, so I would need this to be variable. Like differ every value from column "fruit". 

davehus
Memorable Member
Memorable Member

Hi @Anonymous ,

 

Have you got a date table in your model?

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.

Top Solution Authors