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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
smather
Helper III
Helper III

Measure Help - VAR Formula

I need to do a measure and I'm a lil stuck on the best way to go about it. 

 

Each person logs what they do in a day, and each person can have several entries per day. I need a VAR to assign 1 for each day, for each person, where a certain marker appears. The VAR will need to work when filtered to year, month and even down to day & person. It'd be looking for either a or c in the cat; this can show more than once in a single day for the same person, but it would still only need to to be one 1 and not several. 

 

The data looks a little like this: 

 

NameDate Time StartDate Time EndCatProject
Person 101/01/2022 8:0001/01/2022 10:00a123
Person 101/01/2022 10:0001/01/2022 12:00i123
Person 101/01/2022 12:0001/01/2022 12:30bN/A
Person 201/01/2022 07:0001/01/2022 10:00c321
Person 201/01/2022 10:0001/01/2022 17:00c321
Person 301/01/2022 11:0001/01/2022 14:00fN/A

 

Expected outcome: Person 1 and 2 would show 1 each for the 01/01 but Person 3 would not. 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @smather ;

In your data, here is "a." and "c." ;not "a", "c".

vyalanwumsft_0-1651818128372.png

so you should change the measure.

MyMeasure = 
CALCULATE(DISTINCTCOUNT('Table'[Full Name]), 'Table'[Cat] in {"a.", "c."})

The final output is shown below:

vyalanwumsft_1-1651818176961.pngvyalanwumsft_2-1651818182994.png


Best Regards,
Community Support Team _ Yalan Wu
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

8 REPLIES 8
v-yalanwu-msft
Community Support
Community Support

Hi, @smather ;

In your data, here is "a." and "c." ;not "a", "c".

vyalanwumsft_0-1651818128372.png

so you should change the measure.

MyMeasure = 
CALCULATE(DISTINCTCOUNT('Table'[Full Name]), 'Table'[Cat] in {"a.", "c."})

The final output is shown below:

vyalanwumsft_1-1651818176961.pngvyalanwumsft_2-1651818182994.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PhilipTreacy
Super User
Super User

Hi @smather 

 

Download sample PBIX file

 

This measure works

 

Measure = 

VAR _x = CALCULATE(MINX('Table', [Date Time Start]), FILTER(ALL('Table'), 'Table'[Name] = MIN('Table'[Name])))
VAR _ac = MIN('Table'[Cat]) in {"a", "c"}

RETURN

SWITCH(

    TRUE(),

    _ac && (_x = MIN('Table'[Date Time Start])), 1,

    BLANK()
)

 

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi @PhilipTreacy 

 

I've tried your VAR, and JirkaZ's formula below, but I don't get anything. I just have a blank box. There are filters on the page (to remove breaks/lunch) but even if I remove them, nothing happens 😞 

 

Would it be benifical to share dummy data PBIX?  

Hi @smather 

 

Yes please, it's always beneficial to share the data/file you are working on so we are all working with the same data.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi @PhilipTreacy 

 

See link below. I've removed most identifying information, but the underlying data is what I'm essentially working with. 

 

PBIX Report 

 

Thank you, I appreciate this!

JirkaZ
Solution Specialist
Solution Specialist

Well the easiest would be something like this:

 

SUMX(VALUES(DimDate[Date]), 
   SUMX(VALUES(Person[Name]), IF(CONTAINSSTRING([Cat], "a") OR CONTAINSSTRING([Cat], "c"), 1, 0))
)

 

Just beware that with huge amount of rows it will get slow

Hi @JirkaZ 

 

thanks for replying!! I've tried your formula above, but as the Cat is a SWITCH column, it's not allowing me to reference it. And would this formula account for the fact that a or c could turn up more than once a day for the same engineer? 

JirkaZ
Solution Specialist
Solution Specialist

Yep - you're right.

 

This should work tho: 

 

MyMeasure = SUMX(VALUES('Calendar'[Date]),
CALCULATE(DISTINCTCOUNT(Logs[Person]), Logs[Cat] in {"a", "c"}
))

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.